diff --git a/Cargo.toml b/Cargo.toml index 7c9821e..9f320c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "yup-oauth2" -version = "0.2.2" +version = "0.3.0" authors = ["Sebastian Thiel "] repository = "https://github.com/Byron/yup-oauth2" description = "A partial oauth2 implementation, providing the 'device' authorization flow" diff --git a/examples/auth.rs b/examples/auth.rs index 84c712c..21e57db 100644 --- a/examples/auth.rs +++ b/examples/auth.rs @@ -1,4 +1,5 @@ -#![feature(env, collections, old_io, std_misc)] +#![feature(collections, old_io, std_misc, exit_status)] +#![allow(deprecated)] extern crate "yup-oauth2" as oauth2; extern crate "yup-hyper-mock" as mock; extern crate hyper; diff --git a/src/helper.rs b/src/helper.rs index 6327da9..a931031 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -81,10 +81,14 @@ pub struct Authenticator { } /// A provider for authorization tokens, yielding tokens valid for a given scope. +/// The `api_key()` method is an alternative in case there are no scopes or +/// if no user is involved. pub trait GetToken { fn token<'b, I, T>(&mut self, scopes: I) -> Option where T: Str + Ord, I: IntoIterator; + + fn api_key(&mut self) -> Option; } impl Authenticator @@ -245,6 +249,13 @@ impl GetToken for Authenticator }, } } + + fn api_key(&mut self) -> Option { + if self.secret.client_id.len() == 0 { + return None + } + Some(self.secret.client_id.clone()) + } } diff --git a/src/lib.rs b/src/lib.rs index 645e65f..69d5251 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ -#![feature(io, old_io, std_misc, core, hash)] +#![feature(old_io, std_misc, core, hash)] +#![allow(deprecated)] //! This library can be used to acquire oauth2.0 authentication for services. //! At the time of writing, only one way of doing so is implemented, the [device flow](https://developers.google.com/youtube/v3/guides/authentication#devices), along with a flow //! for [refreshing tokens](https://developers.google.com/youtube/v3/guides/authentication#devices)