credentials_in_body applies to all token request (fixes #6)

This commit is contained in:
Konstantin Stepanov 2016-01-28 14:42:18 +03:00
parent db86c3dfa9
commit 52376a27fc
1 changed files with 6 additions and 6 deletions

View File

@ -112,7 +112,12 @@ impl<P: Provider> Client<P> {
Ok(uri.serialize()) 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 body = form_urlencoded::serialize(body_pairs);
let auth_header = header::Authorization( let auth_header = header::Authorization(
header::Basic { header::Basic {
@ -154,11 +159,6 @@ impl<P: Provider> Client<P> {
body_pairs.push(("redirect_uri", redirect_uri)); 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 json = try!(self.post_token(body_pairs));
let token = try!(P::Token::from_response(&json)); let token = try!(P::Token::from_response(&json));
Ok(token) Ok(token)