pub struct DeviceFlow { /* private fields */ }Expand description
Runs the device flow: start_device_flow,
show the code, then complete_login.
Implementations§
Source§impl DeviceFlow
impl DeviceFlow
Sourcepub fn new(config: AuthConfig) -> Result<Self, AuthError>
pub fn new(config: AuthConfig) -> Result<Self, AuthError>
A flow on the real clock.
Sourcepub fn with_time(
config: AuthConfig,
clock: Arc<dyn Clock>,
sleeper: Arc<dyn Sleeper>,
) -> Result<Self, AuthError>
pub fn with_time( config: AuthConfig, clock: Arc<dyn Clock>, sleeper: Arc<dyn Sleeper>, ) -> Result<Self, AuthError>
A flow with an injected clock and sleep (tests).
Sourcepub async fn start_device_flow(&self) -> Result<DeviceCode, AuthError>
pub async fn start_device_flow(&self) -> Result<DeviceCode, AuthError>
POST {auth_base}/device_authorization (AC1).
Sourcepub async fn poll(
&self,
code: &DeviceCode,
interval: Duration,
) -> Result<PollOutcome, AuthError>
pub async fn poll( &self, code: &DeviceCode, interval: Duration, ) -> Result<PollOutcome, AuthError>
One POST {auth_base}/token for code (AC2). A transport error is
“not yet” (the live API dropped one poll, see the spec’s edge cases).
Sourcepub async fn wait_for_session(
&self,
code: &DeviceCode,
) -> Result<Session, AuthError>
pub async fn wait_for_session( &self, code: &DeviceCode, ) -> Result<Session, AuthError>
Polls until the user approves, the code expires or is denied (AC2), and builds the session from the token response (AC3).
Sourcepub async fn complete_login(
&self,
code: &DeviceCode,
store: &dyn SessionStore,
) -> Result<Login, AuthError>
pub async fn complete_login( &self, code: &DeviceCode, store: &dyn SessionStore, ) -> Result<Login, AuthError>
wait_for_session, one refresh under the
PKCE client (AC19), then saves the session to store. When that
refresh fails for any reason, the grant’s session is saved as is.
Nothing is stored when the login fails.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DeviceFlow
impl !UnwindSafe for DeviceFlow
impl Forget for DeviceFlow
impl Freeze for DeviceFlow
impl Send for DeviceFlow
impl Sync for DeviceFlow
impl Unpin for DeviceFlow
impl UnsafeUnpin for DeviceFlow
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more