From ac749b941c0b2a15c63439908ff5b50be8579fa3 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sat, 27 Feb 2016 19:17:55 -0500 Subject: [PATCH] Add Google Web Provider --- src/lib.rs | 1 + src/provider.rs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index e017aae..a0eae32 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ //! Support for the following OAuth 2.0 providers is included: //! //! - Google +//! - Web //! - Installed //! - GitHub //! - Imgur diff --git a/src/provider.rs b/src/provider.rs index 3177c5a..f7787da 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -40,9 +40,22 @@ pub trait Provider { /// See [Using OAuth 2.0 to Access Google /// APIs](https://developers.google.com/identity/protocols/OAuth2). pub mod google { - use token::{Bearer, Refresh}; + use token::{Bearer, Expiring, Refresh}; use super::Provider; + /// Google OAuth 2.0 provider for web applications. + /// + /// See [Using OAuth 2.0 for Web Server + /// Applications](https://developers.google.com/identity/protocols/OAuth2WebServer). + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub struct Web; + impl Provider for Web { + type Lifetime = Expiring; + type Token = Bearer; + fn auth_uri() -> &'static str { "https://accounts.google.com/o/oauth2/v2/auth" } + fn token_uri() -> &'static str { "https://www.googleapis.com/oauth2/v4/token" } + } + /// Google OAuth 2.0 provider for installed applications. /// /// See [Using OAuth 2.0 for Installed