From 065cfdd22f974afe9d8071e0227929464c1df796 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 10 Apr 2016 13:01:18 +0200 Subject: [PATCH] fix(lib): use hyper Bearer header style Considering we kind-of hardcoded this authentication type anyway, we now use the Auth-types provided by hyper 0.8. The incentive here was the compiler telling us that there the yup-oauth::Scheme type doesn't implement the hyper::authorization::Scheme anymore, even though that clearly was the case. Also it couldn't be reproduced in yup-oauth itself. This will need some work to get correct again, so this is just a crude patch to make it work again. --- src/mako/api/lib/mbuild.mako | 5 ++--- src/rust/api/cmn.rs | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mako/api/lib/mbuild.mako b/src/mako/api/lib/mbuild.mako index 7a5784ff3f..b8ee0d8fd1 100644 --- a/src/mako/api/lib/mbuild.mako +++ b/src/mako/api/lib/mbuild.mako @@ -484,7 +484,7 @@ match result { use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; % endif use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut Delegate = match ${delegate} { Some(d) => d, @@ -690,8 +690,7 @@ else { } } }; - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.access_token }); + let auth_header = Authorization(Bearer { token: token.access_token }); % endif % if request_value: request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); diff --git a/src/rust/api/cmn.rs b/src/rust/api/cmn.rs index 654a11ccf9..da89bc99e8 100644 --- a/src/rust/api/cmn.rs +++ b/src/rust/api/cmn.rs @@ -10,7 +10,7 @@ use mime::{Mime, TopLevel, SubLevel, Attr, Value}; use oauth2::{TokenType, Retry, self}; use hyper; use hyper::header::{ContentType, ContentLength, Headers, UserAgent, Authorization, Header, - HeaderFormat}; + HeaderFormat, Bearer}; use hyper::http::h1::LINE_ENDING; use hyper::method::Method; use hyper::status::StatusCode; @@ -632,7 +632,7 @@ pub struct ResumableUploadHelper<'a, A: 'a> { pub start_at: Option, pub auth: &'a mut A, pub user_agent: &'a str, - pub auth_header: Authorization, + pub auth_header: Authorization, pub url: &'a str, pub reader: &'a mut ReadSeek, pub media_type: Mime,