Add GitHub provider

This commit is contained in:
Curtis McEnroe 2015-12-21 22:28:48 -05:00
parent c3e4d78ad3
commit cd66c77a94
1 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,6 @@
//! Providers. //! Providers.
use token::{Token, Lifetime, Bearer, Expiring}; use token::{Token, Lifetime, Bearer, Static, Expiring};
/// OAuth 2.0 providers. /// OAuth 2.0 providers.
pub trait Provider { pub trait Provider {
@ -32,3 +32,14 @@ impl Provider for Google {
fn auth_uri() -> &'static str { "https://accounts.google.com/o/oauth2/v2/auth" } 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" } fn token_uri() -> &'static str { "https://www.googleapis.com/oauth2/v4/token" }
} }
/// GitHub OAuth 2.0 provider.
///
/// See [OAuth, GitHub Developer Guide](https://developer.github.com/v3/oauth/).
pub struct GitHub;
impl Provider for GitHub {
type Lifetime = Static;
type Token = Bearer<Static>;
fn auth_uri() -> &'static str { "https://github.com/login/oauth/authorize" }
fn token_uri() -> &'static str { "https://github.com/login/oauth/access_token" }
}