diff --git a/examples/github.rs b/examples/github.rs index 982bf77..708b605 100644 --- a/examples/github.rs +++ b/examples/github.rs @@ -7,9 +7,9 @@ use inth_oauth2::provider::GitHub; fn main() { let client = Client::::new( - "01774654cd9a6051e478", - "9f14d16d95d605e715ec1a9aecec220d2565fd5c", - Some("https://cmcenroe.me/oauth2-paste/") + String::from("01774654cd9a6051e478"), + String::from("9f14d16d95d605e715ec1a9aecec220d2565fd5c"), + Some(String::from("https://cmcenroe.me/oauth2-paste/")) ); let auth_uri = client.auth_uri(Some("user"), None).unwrap(); diff --git a/examples/google.rs b/examples/google.rs index d4f70ad..3c91e30 100644 --- a/examples/google.rs +++ b/examples/google.rs @@ -7,9 +7,9 @@ use inth_oauth2::provider::Google; fn main() { let client = Client::::new( - "143225766783-ip2d9qv6sdr37276t77luk6f7bhd6bj5.apps.googleusercontent.com", - "3kZ5WomzHFlN2f_XbhkyPd3o", - Some("urn:ietf:wg:oauth:2.0:oob") + String::from("143225766783-ip2d9qv6sdr37276t77luk6f7bhd6bj5.apps.googleusercontent.com"), + String::from("3kZ5WomzHFlN2f_XbhkyPd3o"), + Some(String::from("urn:ietf:wg:oauth:2.0:oob")) ); let auth_uri = client.auth_uri(Some("https://www.googleapis.com/auth/userinfo.email"), None) diff --git a/examples/imgur.rs b/examples/imgur.rs index 09128e3..ba6f02b 100644 --- a/examples/imgur.rs +++ b/examples/imgur.rs @@ -7,9 +7,9 @@ use inth_oauth2::provider::Imgur; fn main() { let client = Client::::new( - "505c8ca804230e0", - "c898d8cf28404102752b2119a3a1c6aab49899c8", - Some("https://cmcenroe.me/oauth2-paste/") + String::from("505c8ca804230e0"), + String::from("c898d8cf28404102752b2119a3a1c6aab49899c8"), + Some(String::from("https://cmcenroe.me/oauth2-paste/")) ); let auth_uri = client.auth_uri(None, None).unwrap(); diff --git a/src/client/mod.rs b/src/client/mod.rs index 9c1f354..110225c 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -41,20 +41,16 @@ impl Client

{ /// use inth_oauth2::provider::Google; /// /// let client = Client::::new( - /// "CLIENT_ID", - /// "CLIENT_SECRET", - /// Some("urn:ietf:wg:oauth:2.0:oob") + /// String::from("CLIENT_ID"), + /// String::from("CLIENT_SECRET"), + /// Some(String::from("urn:ietf:wg:oauth:2.0:oob")) /// ); /// ``` - pub fn new( - client_id: S, - client_secret: S, - redirect_uri: Option - ) -> Self where S: Into { + pub fn new(client_id: String, client_secret: String, redirect_uri: Option) -> Self { Client { - client_id: client_id.into(), - client_secret: client_secret.into(), - redirect_uri: redirect_uri.map(Into::into), + client_id: client_id, + client_secret: client_secret, + redirect_uri: redirect_uri, provider: PhantomData, } } @@ -70,9 +66,9 @@ impl Client

{ /// use inth_oauth2::provider::Google; /// /// let client = Client::::new( - /// "CLIENT_ID", - /// "CLIENT_SECRET", - /// Some("urn:ietf:wg:oauth:2.0:oob") + /// String::from("CLIENT_ID"), + /// String::from("CLIENT_SECRET"), + /// Some(String::from("urn:ietf:wg:oauth:2.0:oob")) /// ); /// /// let auth_uri = client.auth_uri( @@ -210,7 +206,7 @@ mod tests { #[test] fn auth_uri() { - let client = Client::::new("foo", "bar", None); + let client = Client::::new(String::from("foo"), String::from("bar"), None); assert_eq!( "http://example.com/oauth2/auth?response_type=code&client_id=foo", client.auth_uri(None, None).unwrap() @@ -220,9 +216,9 @@ mod tests { #[test] fn auth_uri_with_redirect_uri() { let client = Client::::new( - "foo", - "bar", - Some("http://example.com/oauth2/callback") + String::from("foo"), + String::from("bar"), + Some(String::from("http://example.com/oauth2/callback")) ); assert_eq!( "http://example.com/oauth2/auth?response_type=code&client_id=foo&redirect_uri=http%3A%2F%2Fexample.com%2Foauth2%2Fcallback", @@ -232,7 +228,7 @@ mod tests { #[test] fn auth_uri_with_scope() { - let client = Client::::new("foo", "bar", None); + let client = Client::::new(String::from("foo"), String::from("bar"), None); assert_eq!( "http://example.com/oauth2/auth?response_type=code&client_id=foo&scope=baz", client.auth_uri(Some("baz"), None).unwrap() @@ -241,7 +237,7 @@ mod tests { #[test] fn auth_uri_with_state() { - let client = Client::::new("foo", "bar", None); + let client = Client::::new(String::from("foo"), String::from("bar"), None); assert_eq!( "http://example.com/oauth2/auth?response_type=code&client_id=foo&state=baz", client.auth_uri(None, Some("baz")).unwrap() diff --git a/src/lib.rs b/src/lib.rs index ddc8478..ef5ff8e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,9 +33,9 @@ //! use inth_oauth2::provider::Google; //! //! let client = Client::::new( -//! "client_id", -//! "client_secret", -//! Some("redirect_uri") +//! String::from("client_id"), +//! String::from("client_secret"), +//! Some(String::from("redirect_uri")) //! ); //! ``` //! @@ -44,7 +44,7 @@ //! ``` //! # use inth_oauth2::Client; //! # use inth_oauth2::provider::Google; -//! # let client = Client::::new("", "", None); +//! # let client = Client::::new(String::new(), String::new(), None); //! let auth_uri = client.auth_uri(Some("scope"), Some("state")).unwrap(); //! println!("Authorize the application by clicking on the link: {}", auth_uri); //! ``` @@ -55,7 +55,7 @@ //! use std::io; //! use inth_oauth2::{Client, Token}; //! # use inth_oauth2::provider::Google; -//! # let client = Client::::new("", "", None); +//! # let client = Client::::new(String::new(), String::new(), None); //! //! let mut code = String::new(); //! io::stdin().read_line(&mut code).unwrap(); @@ -70,7 +70,7 @@ //! ```no_run //! # use inth_oauth2::Client; //! # use inth_oauth2::provider::Google; -//! # let client = Client::::new("", "", None); +//! # let client = Client::::new(String::new(), String::new(), None); //! # let http_client = Default::default(); //! # let token = client.request_token(&http_client, "").unwrap(); //! let token = client.refresh_token(&http_client, token, None).unwrap(); @@ -81,7 +81,7 @@ //! ```no_run //! # use inth_oauth2::Client; //! # use inth_oauth2::provider::Google; -//! # let client = Client::::new("", "", None); +//! # let client = Client::::new(String::new(), String::new(), None); //! # let http_client = Default::default(); //! # let mut token = client.request_token(&http_client, "").unwrap(); //! // Refresh token only if it has expired. @@ -101,7 +101,7 @@ //! //! # fn main() { //! let client = hyper::Client::new(); -//! # let oauth_client = Client::::new("", "", None); +//! # let oauth_client = Client::::new(String::new(), String::new(), None); //! # let token = oauth_client.request_token(&client, "").unwrap(); //! let request = client.get("https://example.com/resource") //! .header(Into::>::into(&token)); @@ -121,7 +121,7 @@ //! use rustc_serialize::json; //! # fn main() { //! # let http_client = Default::default(); -//! # let client = Client::::new("", "", None); +//! # let client = Client::::new(String::new(), String::new(), None); //! # let token = client.request_token(&http_client, "").unwrap(); //! let json = json::encode(&token).unwrap(); //! # } @@ -134,7 +134,7 @@ //! # use inth_oauth2::provider::Google; //! # fn main() { //! # let http_client = Default::default(); -//! # let client = Client::::new("", "", None); +//! # let client = Client::::new(String::new(), String::new(), None); //! # let token = client.request_token(&http_client, "").unwrap(); //! let json = serde_json::to_string(&token).unwrap(); //! # } diff --git a/tests/auth_uri.rs b/tests/auth_uri.rs index 34ee397..39a8790 100644 --- a/tests/auth_uri.rs +++ b/tests/auth_uri.rs @@ -13,9 +13,9 @@ fn assert_get_uri_ok(uri: &str) { #[test] fn google_auth_uri_ok() { let client = Client::::new( - "143225766783-ip2d9qv6sdr37276t77luk6f7bhd6bj5.apps.googleusercontent.com", - "", - Some("urn:ietf:wg:oauth:2.0:oob") + String::from("143225766783-ip2d9qv6sdr37276t77luk6f7bhd6bj5.apps.googleusercontent.com"), + String::new(), + Some(String::from("urn:ietf:wg:oauth:2.0:oob")) ); let auth_uri = client.auth_uri( Some("https://www.googleapis.com/auth/userinfo.email"), @@ -27,9 +27,9 @@ fn google_auth_uri_ok() { #[test] fn github_auth_uri_ok() { let client = Client::::new( - "01774654cd9a6051e478", - "", - Some("https://cmcenroe.me/oauth2-paste/") + String::from("01774654cd9a6051e478"), + String::new(), + Some(String::from("https://cmcenroe.me/oauth2-paste/")) ); let auth_uri = client.auth_uri(Some("user"), Some("state")).unwrap(); assert_get_uri_ok(&auth_uri); @@ -38,9 +38,9 @@ fn github_auth_uri_ok() { #[test] fn imgur_auth_uri_ok() { let client = Client::::new( - "505c8ca804230e0", - "", - Some("https://cmcenroe.me/oauth2-paste/") + String::from("505c8ca804230e0"), + String::new(), + Some(String::from("https://cmcenroe.me/oauth2-paste/")) ); let auth_uri = client.auth_uri(None, Some("state")).unwrap(); assert_get_uri_ok(&auth_uri); diff --git a/tests/mock.rs b/tests/mock.rs index 7d4ce5d..cc083a5 100644 --- a/tests/mock.rs +++ b/tests/mock.rs @@ -59,8 +59,8 @@ mod connector { macro_rules! mock_client { ($p:ty, $c:ty) => { (Client::<$p>::new( - "client_id", - "client_secret", + String::from("client_id"), + String::from("client_secret"), None ), hyper::Client::with_connector(<$c>::default()))