From 52376a27fc1322e02781253a3d83fb1f342949c7 Mon Sep 17 00:00:00 2001 From: Konstantin Stepanov Date: Thu, 28 Jan 2016 14:42:18 +0300 Subject: [PATCH] credentials_in_body applies to all token request (fixes #6) --- src/client/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index a7f8c84..320efff 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -112,7 +112,12 @@ impl Client

{ Ok(uri.serialize()) } - fn post_token(&self, body_pairs: Vec<(&str, &str)>) -> Result { + fn post_token<'a>(&'a self, mut body_pairs: Vec<(&str, &'a str)>) -> Result { + 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 Client

{ 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)