diff --git a/src/authenticator_delegate.rs b/src/authenticator_delegate.rs index 0ac916b..5312c13 100644 --- a/src/authenticator_delegate.rs +++ b/src/authenticator_delegate.rs @@ -140,7 +140,7 @@ pub trait FlowDelegate: Clone + Send + Sync { /// along with the `verification_url`. /// # Notes /// * Will be called exactly once, provided we didn't abort during `request_code` phase. - /// * Will only be called if the Authenticator's flow_type is `FlowType::Device`. + /// * Will only be called if the Authenticator's flow_type is `DeviceFlow`. fn present_user_code(&self, pi: &PollInformation) { println!( "Please enter {} at {} and grant access to this application", diff --git a/src/device.rs b/src/device.rs index 02f19c7..a924f17 100644 --- a/src/device.rs +++ b/src/device.rs @@ -13,7 +13,7 @@ use url::form_urlencoded; use crate::authenticator_delegate::{DefaultFlowDelegate, FlowDelegate, PollInformation, Retry}; use crate::types::{ - ApplicationSecret, Flow, FlowType, GetToken, JsonError, PollError, RequestError, Token, + ApplicationSecret, GetToken, JsonError, PollError, RequestError, Token, }; pub const GOOGLE_DEVICE_CODE_URL: &'static str = "https://accounts.google.com/o/oauth2/device/code"; @@ -99,12 +99,6 @@ pub struct DeviceFlowImpl { wait: Duration, } -impl Flow for DeviceFlowImpl { - fn type_id() -> FlowType { - FlowType::Device(String::new()) - } -} - impl GetToken for DeviceFlowImpl where FD: FlowDelegate + 'static, diff --git a/src/lib.rs b/src/lib.rs index f83144e..523e703 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,6 +101,6 @@ pub use crate::installed::{InstalledFlow, InstalledFlowReturnMethod}; pub use crate::service_account::*; pub use crate::storage::{DiskTokenStorage, MemoryStorage, NullStorage, TokenStorage}; pub use crate::types::{ - ApplicationSecret, ConsoleApplicationSecret, FlowType, GetToken, PollError, RefreshResult, + ApplicationSecret, ConsoleApplicationSecret, GetToken, PollError, RefreshResult, RequestError, Scheme, Token, TokenType, }; diff --git a/src/types.rs b/src/types.rs index 3f96e14..a47a0fa 100644 --- a/src/types.rs +++ b/src/types.rs @@ -8,11 +8,6 @@ use std::str::FromStr; use futures::prelude::*; -/// A marker trait for all Flows -pub trait Flow { - fn type_id() -> FlowType; -} - #[derive(Deserialize, Debug)] pub struct JsonError { pub error: String, @@ -323,24 +318,6 @@ impl Token { } } -/// All known authentication types, for suitable constants -#[derive(Clone)] -pub enum FlowType { - /// [device authentication](https://developers.google.com/youtube/v3/guides/authentication#devices). Only works - /// for certain scopes. - /// Contains the device token URL; for google, that is - /// https://accounts.google.com/o/oauth2/device/code (exported as `GOOGLE_DEVICE_CODE_URL`) - Device(String), - /// [installed app flow](https://developers.google.com/identity/protocols/OAuth2InstalledApp). Required - /// for Drive, Calendar, Gmail...; Requires user to paste a code from the browser. - InstalledInteractive, - /// Same as InstalledInteractive, but uses a redirect: The OAuth provider redirects the user's - /// browser to a web server that is running on localhost. This may not work as well with the - /// Windows Firewall, but is more comfortable otherwise. The integer describes which port to - /// bind to (default: 8080) - InstalledRedirect(u16), -} - /// Represents either 'installed' or 'web' applications in a json secrets file. /// See `ConsoleApplicationSecret` for more information #[derive(Deserialize, Serialize, Clone, Default)]