mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-02-23 15:50:00 +01:00
fix(rustup): (abf0548b5 2015-04-15) (built 2015-04-15)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
|
||||
name = "yup-oauth2"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
|
||||
repository = "https://github.com/Byron/yup-oauth2"
|
||||
description = "A partial oauth2 implementation, providing the 'device' authorization flow"
|
||||
|
||||
@@ -16,8 +16,8 @@ pub enum TokenType {
|
||||
Bearer,
|
||||
}
|
||||
|
||||
impl Str for TokenType {
|
||||
fn as_slice(&self) -> &'static str {
|
||||
impl AsRef<str> for TokenType {
|
||||
fn as_ref(&self) -> &'static str {
|
||||
match *self {
|
||||
TokenType::Bearer => "Bearer"
|
||||
}
|
||||
@@ -50,7 +50,7 @@ impl hyper::header::Scheme for Scheme {
|
||||
}
|
||||
|
||||
fn fmt_scheme(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{} {}", self.token_type.as_slice(), self.access_token)
|
||||
write!(f, "{} {}", self.token_type.as_ref(), self.access_token)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,9 +134,9 @@ pub enum FlowType {
|
||||
Device,
|
||||
}
|
||||
|
||||
impl Str for FlowType {
|
||||
impl AsRef<str> for FlowType {
|
||||
/// Converts itself into a URL string
|
||||
fn as_slice(&self) -> &'static str {
|
||||
fn as_ref(&self) -> &'static str {
|
||||
match *self {
|
||||
FlowType::Device => "https://accounts.google.com/o/oauth2/device/code",
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ impl<C> DeviceFlow<C>
|
||||
/// See test-cases in source code for a more complete example.
|
||||
pub fn request_code<'b, T, I>(&mut self, client_id: &str, client_secret: &str, scopes: I)
|
||||
-> RequestResult
|
||||
where T: Str,
|
||||
where T: AsRef<str>,
|
||||
I: IntoIterator<Item=&'b T> {
|
||||
if self.device_code.len() > 0 {
|
||||
panic!("Must not be called after we have obtained a token and have no error");
|
||||
@@ -152,14 +152,14 @@ impl<C> DeviceFlow<C>
|
||||
let req = form_urlencoded::serialize(
|
||||
[("client_id", client_id),
|
||||
("scope", scopes.into_iter()
|
||||
.map(|s| s.as_slice())
|
||||
.map(|s| s.as_ref())
|
||||
.intersperse(" ")
|
||||
.collect::<String>()
|
||||
.as_slice())].iter().cloned());
|
||||
.as_ref())].iter().cloned());
|
||||
|
||||
match self.client.borrow_mut().post(FlowType::Device.as_slice())
|
||||
match self.client.borrow_mut().post(FlowType::Device.as_ref())
|
||||
.header(ContentType("application/x-www-form-urlencoded".parse().unwrap()))
|
||||
.body(req.as_slice())
|
||||
.body(&*req)
|
||||
.send() {
|
||||
Err(err) => {
|
||||
return RequestResult::Error(Rc::new(err));
|
||||
@@ -250,7 +250,7 @@ impl<C> DeviceFlow<C>
|
||||
|
||||
// We should be ready for a new request
|
||||
let req = form_urlencoded::serialize(
|
||||
[("client_id", self.id.as_slice()),
|
||||
[("client_id", &self.id[..]),
|
||||
("client_secret", &self.secret),
|
||||
("code", &self.device_code),
|
||||
("grant_type", "http://oauth.net/grant_type/device/1.0")]
|
||||
@@ -259,7 +259,7 @@ impl<C> DeviceFlow<C>
|
||||
let json_str =
|
||||
match self.client.borrow_mut().post(GOOGLE_TOKEN_URL)
|
||||
.header(ContentType("application/x-www-form-urlencoded".parse().unwrap()))
|
||||
.body(req.as_slice())
|
||||
.body(&*req)
|
||||
.send() {
|
||||
Err(err) => {
|
||||
return PollResult::Error(Rc::new(err));
|
||||
@@ -280,7 +280,7 @@ impl<C> DeviceFlow<C>
|
||||
Err(_) => {}, // ignore, move on, it's not an error
|
||||
Ok(res) => {
|
||||
pi.server_message = res.error;
|
||||
self.state = match pi.server_message.as_slice() {
|
||||
self.state = match pi.server_message.as_ref() {
|
||||
"access_denied" => PollResult::AccessDenied,
|
||||
"authorization_pending" => PollResult::AuthorizationPending(pi),
|
||||
_ => panic!("server message '{}' not understood", pi.server_message),
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::iter::IntoIterator;
|
||||
use std::borrow::BorrowMut;
|
||||
use std::collections::HashMap;
|
||||
use std::hash::{SipHasher, Hash, Hasher};
|
||||
use std::old_io::timer::sleep;
|
||||
use std::thread::sleep;
|
||||
use std::cmp::min;
|
||||
|
||||
use common::{Token, FlowType, ApplicationSecret};
|
||||
@@ -82,7 +82,7 @@ pub struct Authenticator<D, S, C> {
|
||||
/// if no user is involved.
|
||||
pub trait GetToken {
|
||||
fn token<'b, I, T>(&mut self, scopes: I) -> Option<Token>
|
||||
where T: Str + Ord,
|
||||
where T: AsRef<str> + Ord,
|
||||
I: IntoIterator<Item=&'b T>;
|
||||
|
||||
fn api_key(&mut self) -> Option<String>;
|
||||
@@ -186,11 +186,11 @@ impl<D, S, C> GetToken for Authenticator<D, S, C>
|
||||
/// In any failure case, the returned token will be None, otherwise it is guaranteed to be
|
||||
/// valid for the given scopes.
|
||||
fn token<'b, I, T>(&mut self, scopes: I) -> Option<Token>
|
||||
where T: Str + Ord,
|
||||
where T: AsRef<str> + Ord,
|
||||
I: IntoIterator<Item=&'b T> {
|
||||
let (scope_key, scopes) = {
|
||||
let mut sv: Vec<&str> = scopes.into_iter()
|
||||
.map(|s|s.as_slice())
|
||||
.map(|s|s.as_ref())
|
||||
.collect::<Vec<&str>>();
|
||||
sv.sort();
|
||||
let s = sv.connect(" ");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![feature(old_io, std_misc, core)]
|
||||
#![feature(std_misc, thread_sleep)]
|
||||
#![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
|
||||
@@ -60,7 +60,6 @@
|
||||
//! };
|
||||
//! # }
|
||||
//! ```
|
||||
|
||||
extern crate chrono;
|
||||
|
||||
#[macro_use]
|
||||
|
||||
@@ -69,9 +69,9 @@ impl<C> RefreshFlow<C>
|
||||
.iter().cloned());
|
||||
|
||||
let json_str =
|
||||
match self.client.borrow_mut().post(flow_type.as_slice())
|
||||
match self.client.borrow_mut().post(flow_type.as_ref())
|
||||
.header(ContentType("application/x-www-form-urlencoded".parse().unwrap()))
|
||||
.body(req.as_slice())
|
||||
.body(&*req)
|
||||
.send() {
|
||||
Err(err) => {
|
||||
self.result = RefreshResult::Error(err);
|
||||
|
||||
Reference in New Issue
Block a user