pub struct DeviceFlow { /* private fields */ }Expand description
Manages a complete RFC 8628 device-flow OAuth session.
Provider-agnostic: supply the device-code URL and token URL for any provider that supports the Device Authorization Grant.
Implementations§
Source§impl DeviceFlow
impl DeviceFlow
Sourcepub fn new(
client_id: impl Into<String>,
scopes: Vec<String>,
device_code_url: impl Into<String>,
token_url: impl Into<String>,
) -> OAuthResult<Self>
pub fn new( client_id: impl Into<String>, scopes: Vec<String>, device_code_url: impl Into<String>, token_url: impl Into<String>, ) -> OAuthResult<Self>
Create a new device flow for the given OAuth app and provider endpoints.
device_code_url: the provider’s device-authorization endpointtoken_url: the provider’s token endpoint used during polling
Returns an error if the underlying TLS client cannot be constructed.
Sourcepub async fn request_device_code(&self) -> OAuthResult<DeviceCodeResponse>
pub async fn request_device_code(&self) -> OAuthResult<DeviceCodeResponse>
Step 1 — request a device code from the provider.
Returns the DeviceCodeResponse that you should present to the user
(display user_code and verification_uri).
Sourcepub async fn poll_for_token(
&self,
device_code: &DeviceCodeResponse,
) -> OAuthResult<DeviceTokenResponse>
pub async fn poll_for_token( &self, device_code: &DeviceCodeResponse, ) -> OAuthResult<DeviceTokenResponse>
Step 2 — poll the provider until the user has authorised the device.
Automatically respects the interval returned by step 1 and handles
slow_down responses (which add 5 s to the current interval per spec).
Returns Ok(DeviceTokenResponse) once the user approves the request.
Auto Trait Implementations§
impl Freeze for DeviceFlow
impl !RefUnwindSafe for DeviceFlow
impl Send for DeviceFlow
impl Sync for DeviceFlow
impl Unpin for DeviceFlow
impl UnsafeUnpin for DeviceFlow
impl !UnwindSafe 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