mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-02-23 15:50:00 +01:00
fix(rustup): switch to using io where possible
And adapt to hyper in the same moment
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
|
||||
name = "yup-oauth2"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
|
||||
repository = "https://github.com/Byron/yup-oauth2"
|
||||
description = "A partial oauth2 implementation, providing the 'device' authorization flow"
|
||||
@@ -20,5 +20,5 @@ rustc-serialize = "*"
|
||||
|
||||
[dev-dependencies]
|
||||
getopts = "*"
|
||||
yup-hyper-mock = "*"
|
||||
yup-hyper-mock = ">= 0.1.3"
|
||||
open = "*"
|
||||
|
||||
@@ -10,6 +10,7 @@ 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};
|
||||
|
||||
@@ -192,7 +193,8 @@ impl<C, NC> DeviceFlow<C, NC>
|
||||
// json::Json::from_reader(&mut res)
|
||||
// .ok()
|
||||
// .expect("decode must work!"))).unwrap();
|
||||
let json_str = String::from_utf8(res.read_to_end().unwrap()).unwrap();
|
||||
let mut json_str = String::new();
|
||||
res.read_to_string(&mut json_str).ok().expect("string decode must work");
|
||||
|
||||
// check for error
|
||||
match json::decode::<JsonError>(&json_str) {
|
||||
@@ -267,7 +269,9 @@ impl<C, NC> DeviceFlow<C, NC>
|
||||
return PollResult::Error(err);
|
||||
}
|
||||
Ok(mut res) => {
|
||||
String::from_utf8(res.read_to_end().unwrap()).unwrap()
|
||||
let mut json_str = String::new();
|
||||
res.read_to_string(&mut json_str).ok().expect("string decode must work");
|
||||
json_str
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![feature(old_io, std_misc, core, hash)]
|
||||
#![feature(io, old_io, std_misc, core, hash)]
|
||||
//! 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)
|
||||
|
||||
@@ -8,6 +8,7 @@ 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).
|
||||
///
|
||||
@@ -82,7 +83,9 @@ impl<C, NC> RefreshFlow<C, NC>
|
||||
return &self.result;
|
||||
}
|
||||
Ok(mut res) => {
|
||||
String::from_utf8(res.read_to_end().unwrap()).unwrap()
|
||||
let mut json_str = String::new();
|
||||
res.read_to_string(&mut json_str).ok().expect("string decode must work");
|
||||
json_str
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user