credentials_in_body applies to all token request (fixes #6)
This commit is contained in:
parent
db86c3dfa9
commit
52376a27fc
|
@ -112,7 +112,12 @@ impl<P: Provider> Client<P> {
|
|||
Ok(uri.serialize())
|
||||
}
|
||||
|
||||
fn post_token(&self, body_pairs: Vec<(&str, &str)>) -> Result<Json, ClientError> {
|
||||
fn post_token<'a>(&'a self, mut body_pairs: Vec<(&str, &'a str)>) -> Result<Json, ClientError> {
|
||||
if P::credentials_in_body() {
|
||||
body_pairs.push(("client_id", &self.client_id));
|
||||
body_pairs.push(("client_secret", &self.client_secret));
|
||||
}
|
||||
|
||||
let body = form_urlencoded::serialize(body_pairs);
|
||||
let auth_header = header::Authorization(
|
||||
header::Basic {
|
||||
|
@ -154,11 +159,6 @@ impl<P: Provider> Client<P> {
|
|||
body_pairs.push(("redirect_uri", redirect_uri));
|
||||
}
|
||||
|
||||
if P::credentials_in_body() {
|
||||
body_pairs.push(("client_id", &self.client_id));
|
||||
body_pairs.push(("client_secret", &self.client_secret));
|
||||
}
|
||||
|
||||
let json = try!(self.post_token(body_pairs));
|
||||
let token = try!(P::Token::from_response(&json));
|
||||
Ok(token)
|
||||
|
|
Loading…
Reference in New Issue