diff --git a/Cargo.toml b/Cargo.toml index 6630e9b52..b3038af4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "yup-oauth2" -version = "0.3.5" +version = "0.3.6" authors = ["Sebastian Thiel "] repository = "https://github.com/Byron/yup-oauth2" description = "A partial oauth2 implementation, providing the 'device' authorization flow" diff --git a/src/helper.rs b/src/helper.rs index 564329ea3..dfd9ae062 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -293,8 +293,7 @@ impl GetToken for Authenticator match *rf.refresh_token(self.flow_type, &self.secret.client_id, &self.secret.client_secret, - &t.refresh_token, - scopes.iter()) { + &t.refresh_token) { RefreshResult::Error(ref err) => { match self.delegate.connection_error(err) { Retry::Abort|Retry::Skip => diff --git a/src/lib.rs b/src/lib.rs index c636af433..a5f8acdec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,8 +54,7 @@ //! let mut f = RefreshFlow::new(hyper::Client::new()); //! let new_token = match *f.refresh_token(FlowType::Device, //! "my_client_id", "my_secret", -//! "my_refresh_token", -//! &["https://scope.url"]) { +//! "my_refresh_token") { //! RefreshResult::Success(ref t) => t, //! _ => panic!("bad luck ;)") //! }; diff --git a/src/refresh.rs b/src/refresh.rs index 1c0234aea..6d6bce950 100644 --- a/src/refresh.rs +++ b/src/refresh.rs @@ -1,4 +1,5 @@ use common::{FlowType, JsonError}; +use device::GOOGLE_TOKEN_URL; use chrono::UTC; use hyper; @@ -6,10 +7,8 @@ use hyper::header::ContentType; use rustc_serialize::json; use url::form_urlencoded; use super::Token; -use itertools::Itertools; use std::borrow::BorrowMut; use std::io::Read; -use std::iter::IntoIterator; /// Implements the [Outh2 Refresh Token Flow](https://developers.google.com/youtube/v3/guides/authentication#devices). /// @@ -56,15 +55,12 @@ impl RefreshFlow /// /// # Examples /// Please see the crate landing page for an example. - pub fn refresh_token<'b, I, T>( &mut self, - flow_type: FlowType, - client_id: &str, - client_secret: &str, - refresh_token: &str, - scopes: I) - -> &RefreshResult - where T: AsRef + Ord, - I: IntoIterator { + pub fn refresh_token(&mut self, + flow_type: FlowType, + client_id: &str, + client_secret: &str, + refresh_token: &str) -> &RefreshResult { + let _ = flow_type; if let RefreshResult::Success(_) = self.result { return &self.result; } @@ -73,16 +69,11 @@ impl RefreshFlow [("client_id", client_id), ("client_secret", client_secret), ("refresh_token", refresh_token), - ("grant_type", "refresh_token"), - ("scope", scopes.into_iter() - .map(|s| s.as_ref()) - .intersperse(" ") - .collect::() - .as_ref())] + ("grant_type", "refresh_token")] .iter().cloned()); let json_str = - match self.client.borrow_mut().post(flow_type.as_ref()) + match self.client.borrow_mut().post(GOOGLE_TOKEN_URL) .header(ContentType("application/x-www-form-urlencoded".parse().unwrap())) .body(&*req) .send() { @@ -153,7 +144,7 @@ mod tests { match *flow.refresh_token(FlowType::Device, - "bogus", "secret", "bogus_refresh_token", &["scope.url"]) { + "bogus", "secret", "bogus_refresh_token") { RefreshResult::Success(ref t) => { assert_eq!(t.access_token, "1/fFAGRNJru1FTz70BzhT3Zg"); assert!(!t.expired());