diff --git a/examples/google-installed.rs b/examples/google-installed.rs index f83f64e..4659d7e 100644 --- a/examples/google-installed.rs +++ b/examples/google-installed.rs @@ -3,13 +3,13 @@ extern crate inth_oauth2; use std::io; use inth_oauth2::Client; -use inth_oauth2::provider::google::Installed; +use inth_oauth2::provider::google::{Installed, REDIRECT_URI_OOB}; fn main() { let client = Client::::new( String::from("143225766783-ip2d9qv6sdr37276t77luk6f7bhd6bj5.apps.googleusercontent.com"), String::from("3kZ5WomzHFlN2f_XbhkyPd3o"), - Some(String::from("urn:ietf:wg:oauth:2.0:oob")) + Some(String::from(REDIRECT_URI_OOB)), ); let auth_uri = client.auth_uri(Some("https://www.googleapis.com/auth/userinfo.email"), None) diff --git a/src/provider.rs b/src/provider.rs index f7787da..f41e115 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -43,6 +43,21 @@ pub mod google { use token::{Bearer, Expiring, Refresh}; use super::Provider; + /// Signals the server to return the authorization code by prompting the user to copy and + /// paste. + /// + /// See [Choosing a redirect URI][uri]. + /// + /// [uri]: https://developers.google.com/identity/protocols/OAuth2InstalledApp#choosingredirecturi + pub const REDIRECT_URI_OOB: &'static str = "urn:ietf:wg:oauth:2.0:oob"; + + /// Signals the server to return the authorization code in the page title. + /// + /// See [Choosing a redirect URI][uri]. + /// + /// [uri]: https://developers.google.com/identity/protocols/OAuth2InstalledApp#choosingredirecturi + pub const REDIRECT_URI_OOB_AUTO: &'static str = "urn:ietf:wg:oauth:2.0:oob:auto"; + /// Google OAuth 2.0 provider for web applications. /// /// See [Using OAuth 2.0 for Web Server