test(auth): removed DeviceFlowHelper

It's superseded by the more powerful `Authenticator`.
Adjusted library documentation accordingly, as well as `auth` program.
This commit is contained in:
Sebastian Thiel
2015-02-28 12:03:30 +01:00
parent 374804331a
commit dea3e6b3fd
4 changed files with 64 additions and 176 deletions

View File

@@ -16,27 +16,26 @@
//! ```test_harness,no_run
//! extern crate hyper;
//! extern crate "yup-oauth2" as oauth2;
//! use oauth2::{DeviceFlowHelper, DeviceFlowHelperDelegate, PollInformation};
//! extern crate "rustc-serialize" as rustc_serialize;
//!
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, PollInformation, ConsoleApplicationSecret, MemoryStorage};
//! use rustc_serialize::json;
//! use std::default::Default;
//! # const SECRET: &'static str = "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"UqkDJd5RFwnHoiG5x5Rub8SI\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}";
//!
//! # #[test] fn device() {
//! struct PrintHandler;
//! impl DeviceFlowHelperDelegate for PrintHandler {
//! fn present_user_code(&mut self, pi: PollInformation) {
//! println!{"Please enter {} at {} and grant access to this application",
//! pi.user_code, pi.verification_url}
//! println!("Do not close this application until you either denied or granted access");
//! }
//! }
//! if let Some(t) = DeviceFlowHelper::new(&mut PrintHandler)
//! .retrieve_token(hyper::Client::new(),
//! "your_client_id",
//! "your_secret",
//! &["https://www.googleapis.com/auth/youtube.upload"]) {
//! let secret = json::decode::<ConsoleApplicationSecret>(SECRET).unwrap().installed.unwrap();
//! let res = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
//! hyper::Client::new(),
//! <MemoryStorage as Default>::default(), None)
//! .token(&["https://www.googleapis.com/auth/youtube.upload"]);
//! match res {
//! Some(t) => {
//! // now you can use t.access_token to authenticate API calls within your
//! // given scopes. It will not be valid forever, which is when you have to
//! // refresh it using the `RefreshFlow`
//! } else {
//! println!("user declined");
//! },
//! None => println!("user declined"),
//! }
//! # }
//! ```
@@ -80,7 +79,8 @@ mod refresh;
mod common;
mod helper;
pub use device::{DeviceFlow, PollInformation, PollResult, DeviceFlowHelper,
DeviceFlowHelperDelegate, Retry};
pub use device::{DeviceFlow, PollInformation, PollResult};
pub use refresh::{RefreshFlow, RefreshResult};
pub use common::{Token, FlowType, ApplicationSecret, ConsoleApplicationSecret};
pub use helper::{TokenStorage, NullStorage, MemoryStorage, Authenticator,
AuthenticatorDelegate, Retry, DefaultAuthenticatorDelegate};