Update reqwest to 0.9.5

Have remove impl Into<header::Authorization<header::Bearer>> for Bearer
because Authorization does not exist any more
This commit is contained in:
edelangh 2018-10-12 16:25:31 +02:00
parent 00f6b4ac13
commit ff8b0aea71
3 changed files with 19 additions and 27 deletions

View File

@ -18,4 +18,4 @@ serde = "1.0.8"
serde_derive = "1.0.5"
serde_json = "1.0.2"
url = "1.1.0"
reqwest = "0.8.0"
reqwest = "0.9.2"

View File

@ -5,15 +5,16 @@ mod error;
pub mod response;
pub use self::error::ClientError;
use reqwest::{self, header, mime};
use reqwest;
use reqwest::header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE};
use serde_json::{self, Value};
use url::Url;
use url::form_urlencoded::Serializer;
use url::Url;
use client::response::FromResponse;
use error::OAuth2Error;
use provider::Provider;
use token::{Token, Lifetime, Refresh};
use token::{Lifetime, Refresh, Token};
/// OAuth 2.0 client.
#[derive(Debug, Clone, PartialEq, Eq)]
@ -110,28 +111,20 @@ impl<P: Provider> Client<P> {
fn post_token(
&self,
http_client: &reqwest::Client,
mut body: Serializer<String>
mut body: Serializer<String>,
) -> Result<Value, ClientError> {
if self.provider.credentials_in_body() {
body.append_pair("client_id", &self.client_id);
body.append_pair("client_secret", &self.client_secret);
}
let auth_header = header::Authorization(
header::Basic {
username: self.client_id.clone(),
password: Some(self.client_secret.clone()),
}
);
let accept_header = header::Accept(vec![
header::qitem(mime::APPLICATION_JSON),
]);
let body = body.finish();
let mut response = http_client.post(self.provider.token_uri().clone())
.header(auth_header)
.header(accept_header)
.header(header::ContentType::form_url_encoded())
let mut response = http_client
.post(self.provider.token_uri().clone())
.basic_auth(&self.client_id, Some(&self.client_secret))
.header(ACCEPT, "application/json")
.header(CONTENT_TYPE, "application/x-www-form-urlencoded")
.body(body)
.send()?;

View File

@ -1,4 +1,3 @@
use reqwest::header;
use serde_json::Value;
use client::response::{FromResponse, ParseError};
@ -15,14 +14,14 @@ pub struct Bearer<L: Lifetime> {
}
impl<L: Lifetime> Token<L> for Bearer<L> {
fn access_token(&self) -> &str { &self.access_token }
fn scope(&self) -> Option<&str> { self.scope.as_ref().map(|s| &s[..]) }
fn lifetime(&self) -> &L { &self.lifetime }
}
impl<'a, L: Lifetime> Into<header::Authorization<header::Bearer>> for &'a Bearer<L> {
fn into(self) -> header::Authorization<header::Bearer> {
header::Authorization(header::Bearer { token: self.access_token.clone() })
fn access_token(&self) -> &str {
&self.access_token
}
fn scope(&self) -> Option<&str> {
self.scope.as_ref().map(|s| &s[..])
}
fn lifetime(&self) -> &L {
&self.lifetime
}
}