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)