diff --git a/Cargo.toml b/Cargo.toml index ffccfed..e8d72f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ rustls = "0.9.0" serde = "1.0" serde_json = "1.0" serde_derive = "1.0" -url = "0.5" +url = "1" [dev-dependencies] getopts = "0.2" diff --git a/src/device.rs b/src/device.rs index f61ca50..da5090f 100644 --- a/src/device.rs +++ b/src/device.rs @@ -87,13 +87,14 @@ impl DeviceFlow // note: cloned() shouldn't be needed, see issue // https://github.com/servo/rust-url/issues/81 - let req = form_urlencoded::serialize(&[("client_id", &self.application_secret.client_id), - ("scope", - &scopes.into_iter() - .map(|s| s.as_ref()) - .intersperse(" ") - .collect::() - )]); + let req = form_urlencoded::Serializer::new(String::new()) + .extend_pairs(&[("client_id", &self.application_secret.client_id), + ("scope", &scopes + .into_iter() + .map(|s| s.as_ref()) + .intersperse(" ") + .collect::())]) + .finish(); // note: works around bug in rustlang // https://github.com/rust-lang/rust/issues/22252 @@ -182,11 +183,12 @@ impl DeviceFlow } // We should be ready for a new request - let req = form_urlencoded::serialize(&[("client_id", &self.application_secret.client_id[..]), - ("client_secret", &self.application_secret.client_secret), - ("code", &self.device_code), - ("grant_type", - "http://oauth.net/grant_type/device/1.0")]); + let req = form_urlencoded::Serializer::new(String::new()) + .extend_pairs(&[("client_id", &self.application_secret.client_id[..]), + ("client_secret", &self.application_secret.client_secret), + ("code", &self.device_code), + ("grant_type", "http://oauth.net/grant_type/device/1.0")]) + .finish(); let json_str: String = match self.client .borrow_mut() diff --git a/src/installed.rs b/src/installed.rs index 300f84e..c3b6f3c 100644 --- a/src/installed.rs +++ b/src/installed.rs @@ -52,7 +52,7 @@ fn build_authentication_request_url<'a, T, I>(auth_uri: &str, format!("&client_id={}", client_id)] .into_iter() .fold(url, |mut u, param| { - u.push_str(&percent_encode(param.as_ref(), QUERY_ENCODE_SET)); + u.push_str(&percent_encode(param.as_ref(), QUERY_ENCODE_SET).to_string()); u }) } @@ -221,14 +221,13 @@ impl InstalledFlow Some(p) => redirect_uri = format!("http://localhost:{}", p), } - let body = form_urlencoded::serialize(vec![("code".to_string(), authcode.to_string()), - ("client_id".to_string(), - appsecret.client_id.clone()), - ("client_secret".to_string(), - appsecret.client_secret.clone()), - ("redirect_uri".to_string(), redirect_uri), - ("grant_type".to_string(), - "authorization_code".to_string())]); + let body = form_urlencoded::Serializer::new(String::new()) + .extend_pairs(vec![("code".to_string(), authcode.to_string()), + ("client_id".to_string(), appsecret.client_id.clone()), + ("client_secret".to_string(), appsecret.client_secret.clone()), + ("redirect_uri".to_string(), redirect_uri), + ("grant_type".to_string(), "authorization_code".to_string())]) + .finish(); let result: Result = self.client .borrow_mut() diff --git a/src/refresh.rs b/src/refresh.rs index f68dd54..883a59b 100644 --- a/src/refresh.rs +++ b/src/refresh.rs @@ -64,10 +64,12 @@ impl RefreshFlow return &self.result; } - let req = form_urlencoded::serialize(&[("client_id", client_secret.client_id.as_ref()), - ("client_secret", client_secret.client_secret.as_ref()), - ("refresh_token", refresh_token), - ("grant_type", "refresh_token")]); + let req = form_urlencoded::Serializer::new(String::new()) + .extend_pairs(&[("client_id", client_secret.client_id.as_ref()), + ("client_secret", client_secret.client_secret.as_ref()), + ("refresh_token", refresh_token), + ("grant_type", "refresh_token")]) + .finish(); let json_str: String = match self.client .borrow_mut() diff --git a/src/service_account.rs b/src/service_account.rs index 80a5bf3..6fc0c10 100644 --- a/src/service_account.rs +++ b/src/service_account.rs @@ -220,9 +220,10 @@ impl<'a, C> ServiceAccountAccess let signed = try!(JWT::new(claims) .sign(self.key.private_key.as_ref().unwrap())); - let body = form_urlencoded::serialize(vec![("grant_type".to_string(), - GRANT_TYPE.to_string()), - ("assertion".to_string(), signed)]); + let body = form_urlencoded::Serializer::new(String::new()) + .extend_pairs(vec![("grant_type".to_string(), GRANT_TYPE.to_string()), + ("assertion".to_string(), signed)]) + .finish(); let mut response = String::new(); let mut result = try!(self.client