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:
parent
00f6b4ac13
commit
ff8b0aea71
|
@ -18,4 +18,4 @@ serde = "1.0.8"
|
||||||
serde_derive = "1.0.5"
|
serde_derive = "1.0.5"
|
||||||
serde_json = "1.0.2"
|
serde_json = "1.0.2"
|
||||||
url = "1.1.0"
|
url = "1.1.0"
|
||||||
reqwest = "0.8.0"
|
reqwest = "0.9.2"
|
||||||
|
|
|
@ -5,15 +5,16 @@ mod error;
|
||||||
pub mod response;
|
pub mod response;
|
||||||
pub use self::error::ClientError;
|
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 serde_json::{self, Value};
|
||||||
use url::Url;
|
|
||||||
use url::form_urlencoded::Serializer;
|
use url::form_urlencoded::Serializer;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
use client::response::FromResponse;
|
use client::response::FromResponse;
|
||||||
use error::OAuth2Error;
|
use error::OAuth2Error;
|
||||||
use provider::Provider;
|
use provider::Provider;
|
||||||
use token::{Token, Lifetime, Refresh};
|
use token::{Lifetime, Refresh, Token};
|
||||||
|
|
||||||
/// OAuth 2.0 client.
|
/// OAuth 2.0 client.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
@ -110,28 +111,20 @@ impl<P: Provider> Client<P> {
|
||||||
fn post_token(
|
fn post_token(
|
||||||
&self,
|
&self,
|
||||||
http_client: &reqwest::Client,
|
http_client: &reqwest::Client,
|
||||||
mut body: Serializer<String>
|
mut body: Serializer<String>,
|
||||||
) -> Result<Value, ClientError> {
|
) -> Result<Value, ClientError> {
|
||||||
if self.provider.credentials_in_body() {
|
if self.provider.credentials_in_body() {
|
||||||
body.append_pair("client_id", &self.client_id);
|
body.append_pair("client_id", &self.client_id);
|
||||||
body.append_pair("client_secret", &self.client_secret);
|
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 body = body.finish();
|
||||||
|
|
||||||
let mut response = http_client.post(self.provider.token_uri().clone())
|
let mut response = http_client
|
||||||
.header(auth_header)
|
.post(self.provider.token_uri().clone())
|
||||||
.header(accept_header)
|
.basic_auth(&self.client_id, Some(&self.client_secret))
|
||||||
.header(header::ContentType::form_url_encoded())
|
.header(ACCEPT, "application/json")
|
||||||
|
.header(CONTENT_TYPE, "application/x-www-form-urlencoded")
|
||||||
.body(body)
|
.body(body)
|
||||||
.send()?;
|
.send()?;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use reqwest::header;
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use client::response::{FromResponse, ParseError};
|
use client::response::{FromResponse, ParseError};
|
||||||
|
@ -15,14 +14,14 @@ pub struct Bearer<L: Lifetime> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<L: Lifetime> Token<L> for Bearer<L> {
|
impl<L: Lifetime> Token<L> for Bearer<L> {
|
||||||
fn access_token(&self) -> &str { &self.access_token }
|
fn access_token(&self) -> &str {
|
||||||
fn scope(&self) -> Option<&str> { self.scope.as_ref().map(|s| &s[..]) }
|
&self.access_token
|
||||||
fn lifetime(&self) -> &L { &self.lifetime }
|
}
|
||||||
}
|
fn scope(&self) -> Option<&str> {
|
||||||
|
self.scope.as_ref().map(|s| &s[..])
|
||||||
impl<'a, L: Lifetime> Into<header::Authorization<header::Bearer>> for &'a Bearer<L> {
|
}
|
||||||
fn into(self) -> header::Authorization<header::Bearer> {
|
fn lifetime(&self) -> &L {
|
||||||
header::Authorization(header::Bearer { token: self.access_token.clone() })
|
&self.lifetime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue