Merge branch 'next'

This commit is contained in:
Sebastian Thiel
2015-03-16 13:42:12 +01:00
4 changed files with 16 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
[package]
name = "yup-oauth2"
version = "0.2.2"
version = "0.3.0"
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
repository = "https://github.com/Byron/yup-oauth2"
description = "A partial oauth2 implementation, providing the 'device' authorization flow"

View File

@@ -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;

View File

@@ -81,10 +81,14 @@ pub struct Authenticator<D, S, C, NC> {
}
/// 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<Token>
where T: Str + Ord,
I: IntoIterator<Item=&'b T>;
fn api_key(&mut self) -> Option<String>;
}
impl<D, S, C, NC> Authenticator<D, S, C, NC>
@@ -245,6 +249,13 @@ impl<D, S, C, NC> GetToken for Authenticator<D, S, C, NC>
},
}
}
fn api_key(&mut self) -> Option<String> {
if self.secret.client_id.len() == 0 {
return None
}
Some(self.secret.client_id.clone())
}
}

View File

@@ -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)