pub struct DeviceCodeLogin { /* private fields */ }Expand description
A login with the Device Authorization Grant that is waiting for the
end-user to grant the authorization, returned by
OAuth::login_with_device_code().
The verification URI and the user code must be presented to the end-user,
who must open the URI in a browser on another device and enter the user
code if necessary. Then DeviceCodeLogin::finish() must be called to
wait for the authorization and complete the login.
Implementations§
Source§impl DeviceCodeLogin
impl DeviceCodeLogin
Sourcepub fn device_id(&self) -> &DeviceId
pub fn device_id(&self) -> &DeviceId
The device ID that will be associated with the session.
This is either the device ID that was passed to
OAuth::login_with_device_code(), or the one that was generated if
none was provided.
Sourcepub fn verification_uri(&self) -> &Url
pub fn verification_uri(&self) -> &Url
The end-user verification URI on the authorization server.
The end-user should open this URI in a browser and enter the
user_code().
Sourcepub fn verification_uri_complete(&self) -> Option<&Url>
pub fn verification_uri_complete(&self) -> Option<&Url>
A verification URI that includes the user_code(),
designed for non-textual transmission, for example in a QR code.
This is optional, and complements the
verification_uri() and the
user_code() rather than replacing them: if it is
available, it can be presented in addition to them, so the end-user
doesn’t need to enter the user code manually. The verification URI and
the user code should still be displayed, as a fallback for an end-user
that cannot use this URI, and so the user code can be compared with the
one shown by the authorization server.
See RFC 8628 section 3.3.1 for more details.
Sourcepub fn expires_in(&self) -> Duration
pub fn expires_in(&self) -> Duration
The lifetime of the device code and user code, from the moment received.
If the end-user doesn’t grant the authorization before this delay,
DeviceCodeLogin::finish() fails with
DeviceCodeLoginError::ExpiredToken.
Sourcepub async fn finish(self) -> Result<(), DeviceCodeLoginError>
pub async fn finish(self) -> Result<(), DeviceCodeLoginError>
Wait for the end-user to grant the authorization, and complete the login.
This polls the OAuth 2.0 authorization server until the authorization
is granted, denied, or until it expires. When the authorization is
granted, the session is loaded into the client, like with
OAuth::finish_login().
Dropping the returned future while it is waiting for the end-user to grant the authorization stops polling the authorization server and leaves the client unchanged. Once the authorization is granted, the access token is set on the client and the session is loaded: if the future is dropped during this step, the client may be left partially logged in and should not be used anymore.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DeviceCodeLogin
impl !UnwindSafe for DeviceCodeLogin
impl Freeze for DeviceCodeLogin
impl Send for DeviceCodeLogin
impl Sync for DeviceCodeLogin
impl Unpin for DeviceCodeLogin
impl UnsafeUnpin for DeviceCodeLogin
Blanket Implementations§
impl<T> AsyncTraitDeps for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> Fruit for T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more