mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-01-04 18:30:26 +01:00
fix(version-up): v0.3.3
* hyper adjustments to deal with Client without type parameter * adjust to changed crate name conventions, '-' are converted to '_' Fixes #3
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
|
||||
name = "yup-oauth2"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
|
||||
repository = "https://github.com/Byron/yup-oauth2"
|
||||
description = "A partial oauth2 implementation, providing the 'device' authorization flow"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![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 yup_oauth2 as oauth2;
|
||||
extern crate yup_hyper_mock as mock;
|
||||
extern crate hyper;
|
||||
extern crate chrono;
|
||||
extern crate getopts;
|
||||
|
||||
@@ -10,7 +10,6 @@ use itertools::Itertools;
|
||||
use rustc_serialize::json;
|
||||
use chrono::{DateTime,UTC};
|
||||
use std::borrow::BorrowMut;
|
||||
use std::marker::PhantomData;
|
||||
use std::io::Read;
|
||||
|
||||
use common::{Token, FlowType, Flow};
|
||||
@@ -21,17 +20,15 @@ pub const GOOGLE_TOKEN_URL: &'static str = "https://accounts.google.com/o/oauth2
|
||||
/// It operates in two steps:
|
||||
/// * obtain a code to show to the user
|
||||
/// * (repeatedly) poll for the user to authenticate your application
|
||||
pub struct DeviceFlow<C, NC> {
|
||||
pub struct DeviceFlow<C> {
|
||||
client: C,
|
||||
device_code: String,
|
||||
state: PollResult,
|
||||
secret: String,
|
||||
id: String,
|
||||
|
||||
_m: PhantomData<NC>,
|
||||
}
|
||||
|
||||
impl<C, NC> Flow for DeviceFlow<C, NC> {
|
||||
impl<C> Flow for DeviceFlow<C> {
|
||||
fn type_id() -> FlowType {
|
||||
FlowType::Device
|
||||
}
|
||||
@@ -103,28 +100,26 @@ impl Default for PollResult {
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, NC> DeviceFlow<C, NC>
|
||||
where C: BorrowMut<hyper::Client<NC>>,
|
||||
NC: hyper::net::NetworkConnector {
|
||||
impl<C> DeviceFlow<C>
|
||||
where C: BorrowMut<hyper::Client> {
|
||||
|
||||
/// # Examples
|
||||
/// ```test_harness
|
||||
/// extern crate hyper;
|
||||
/// extern crate "yup-oauth2" as oauth2;
|
||||
/// extern crate yup_oauth2 as oauth2;
|
||||
/// use oauth2::DeviceFlow;
|
||||
///
|
||||
/// # #[test] fn new() {
|
||||
/// let mut f = DeviceFlow::new(hyper::Client::new());
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn new(client: C) -> DeviceFlow<C, NC> {
|
||||
pub fn new(client: C) -> DeviceFlow<C> {
|
||||
DeviceFlow {
|
||||
client: client,
|
||||
device_code: Default::default(),
|
||||
secret: Default::default(),
|
||||
id: Default::default(),
|
||||
state: Default::default(),
|
||||
_m: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::iter::IntoIterator;
|
||||
use std::borrow::BorrowMut;
|
||||
use std::marker::PhantomData;
|
||||
use std::collections::HashMap;
|
||||
use std::hash::{SipHasher, Hash, Hasher};
|
||||
use std::old_io::timer::sleep;
|
||||
@@ -70,14 +69,12 @@ impl TokenStorage for MemoryStorage {
|
||||
///
|
||||
/// # Usage
|
||||
/// Please have a look at the library's landing page.
|
||||
pub struct Authenticator<D, S, C, NC> {
|
||||
pub struct Authenticator<D, S, C> {
|
||||
flow_type: FlowType,
|
||||
delegate: D,
|
||||
storage: S,
|
||||
client: C,
|
||||
secret: ApplicationSecret,
|
||||
|
||||
_m: PhantomData<NC>
|
||||
}
|
||||
|
||||
/// A provider for authorization tokens, yielding tokens valid for a given scope.
|
||||
@@ -91,11 +88,10 @@ pub trait GetToken {
|
||||
fn api_key(&mut self) -> Option<String>;
|
||||
}
|
||||
|
||||
impl<D, S, C, NC> Authenticator<D, S, C, NC>
|
||||
impl<D, S, C> Authenticator<D, S, C>
|
||||
where D: AuthenticatorDelegate,
|
||||
S: TokenStorage,
|
||||
NC: hyper::net::NetworkConnector,
|
||||
C: BorrowMut<hyper::Client<NC>> {
|
||||
C: BorrowMut<hyper::Client> {
|
||||
|
||||
|
||||
/// Returns a new `Authenticator` instance
|
||||
@@ -113,14 +109,13 @@ impl<D, S, C, NC> Authenticator<D, S, C, NC>
|
||||
/// [dev-con]: https://console.developers.google.com
|
||||
pub fn new(secret: &ApplicationSecret,
|
||||
delegate: D, client: C, storage: S, flow_type: Option<FlowType>)
|
||||
-> Authenticator<D, S, C, NC> {
|
||||
-> Authenticator<D, S, C> {
|
||||
Authenticator {
|
||||
flow_type: flow_type.unwrap_or(FlowType::Device),
|
||||
delegate: delegate,
|
||||
storage: storage,
|
||||
client: client,
|
||||
secret: secret.clone(),
|
||||
_m: PhantomData
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,11 +176,10 @@ impl<D, S, C, NC> Authenticator<D, S, C, NC>
|
||||
}
|
||||
}
|
||||
|
||||
impl<D, S, C, NC> GetToken for Authenticator<D, S, C, NC>
|
||||
impl<D, S, C> GetToken for Authenticator<D, S, C>
|
||||
where D: AuthenticatorDelegate,
|
||||
S: TokenStorage,
|
||||
NC: hyper::net::NetworkConnector,
|
||||
C: BorrowMut<hyper::Client<NC>> {
|
||||
C: BorrowMut<hyper::Client> {
|
||||
|
||||
/// Blocks until a token was retrieved from storage, from the server, or until the delegate
|
||||
/// decided to abort the attempt, or the user decided not to authorize the application.
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
//!
|
||||
//! ```test_harness,no_run
|
||||
//! extern crate hyper;
|
||||
//! extern crate "yup-oauth2" as oauth2;
|
||||
//! extern crate "rustc-serialize" as rustc_serialize;
|
||||
//! extern crate yup_oauth2 as oauth2;
|
||||
//! extern crate rustc_serialize;
|
||||
//!
|
||||
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, PollInformation, ConsoleApplicationSecret, MemoryStorage, GetToken};
|
||||
//! use rustc_serialize::json;
|
||||
@@ -47,7 +47,7 @@
|
||||
//!
|
||||
//! ```test_harness,no_run
|
||||
//! extern crate hyper;
|
||||
//! extern crate "yup-oauth2" as oauth2;
|
||||
//! extern crate yup_oauth2 as oauth2;
|
||||
//! use oauth2::{RefreshFlow, FlowType, RefreshResult};
|
||||
//!
|
||||
//! # #[test] fn refresh() {
|
||||
|
||||
@@ -7,7 +7,6 @@ use rustc_serialize::json;
|
||||
use url::form_urlencoded;
|
||||
use super::Token;
|
||||
use std::borrow::BorrowMut;
|
||||
use std::marker::PhantomData;
|
||||
use std::io::Read;
|
||||
|
||||
/// Implements the [Outh2 Refresh Token Flow](https://developers.google.com/youtube/v3/guides/authentication#devices).
|
||||
@@ -15,11 +14,9 @@ use std::io::Read;
|
||||
/// Refresh an expired access token, as obtained by any other authentication flow.
|
||||
/// This flow is useful when your `Token` is expired and allows to obtain a new
|
||||
/// and valid access token.
|
||||
pub struct RefreshFlow<C, NC> {
|
||||
pub struct RefreshFlow<C> {
|
||||
client: C,
|
||||
result: RefreshResult,
|
||||
|
||||
_m: PhantomData<NC>,
|
||||
}
|
||||
|
||||
|
||||
@@ -33,15 +30,13 @@ pub enum RefreshResult {
|
||||
Success(Token),
|
||||
}
|
||||
|
||||
impl<C, NC> RefreshFlow<C, NC>
|
||||
where NC: hyper::net::NetworkConnector,
|
||||
C: BorrowMut<hyper::Client<NC>> {
|
||||
impl<C> RefreshFlow<C>
|
||||
where C: BorrowMut<hyper::Client> {
|
||||
|
||||
pub fn new(client: C) -> RefreshFlow<C, NC> {
|
||||
pub fn new(client: C) -> RefreshFlow<C> {
|
||||
RefreshFlow {
|
||||
client: client,
|
||||
result: RefreshResult::Error(hyper::HttpError::HttpStatusError),
|
||||
_m: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user