[][src]Trait yup_oauth2::AuthenticatorDelegate

pub trait AuthenticatorDelegate {
    fn connection_error(&mut self, _: &Error) -> Retry { ... }
fn token_storage_failure(&mut self, is_set: bool, _: &dyn Error) -> Retry { ... }
fn request_failure(&mut self, _: RequestError) { ... }
fn expired(&mut self, _: &DateTime<Utc>) { ... }
fn denied(&mut self) { ... }
fn token_refresh_failed(
        &mut self,
        error: &String,
        error_description: &Option<String>
    ) { ... }
fn pending(&mut self, _: &PollInformation) -> Retry { ... }
fn present_user_code(&mut self, pi: &PollInformation) { ... }
fn present_user_url(
        &mut self,
        url: &String,
        need_code: bool
    ) -> Option<String> { ... } }

A partially implemented trait to interact with the Authenticator

The only method that needs to be implemented manually is present_user_code(...), as no assumptions are made on how this presentation should happen.

Provided methods

fn connection_error(&mut self, _: &Error) -> Retry

Called whenever there is an HttpError, usually if there are network problems.

Return retry information.

fn token_storage_failure(&mut self, is_set: bool, _: &dyn Error) -> Retry

Called whenever we failed to retrieve a token or set a token due to a storage error. You may use it to either ignore the incident or retry. This can be useful if the underlying TokenStorage may fail occasionally. if is_set is true, the failure resulted from TokenStorage.set(...). Otherwise, it was TokenStorage.get(...)

fn request_failure(&mut self, _: RequestError)

The server denied the attempt to obtain a request code

fn expired(&mut self, _: &DateTime<Utc>)

Called if the request code is expired. You will have to start over in this case. This will be the last call the delegate receives. Given DateTime is the expiration date

fn denied(&mut self)

Called if the user denied access. You would have to start over. This will be the last call the delegate receives.

fn token_refresh_failed(
    &mut self,
    error: &String,
    error_description: &Option<String>
)

Called if we could not acquire a refresh token for a reason possibly specified by the server. This call is made for the delegate's information only.

fn pending(&mut self, _: &PollInformation) -> Retry

Called as long as we are waiting for the user to authorize us. Can be used to print progress information, or decide to time-out.

If the returned Retry variant is a duration.

Notes

  • Only used in DeviceFlow. Return value will only be used if it is larger than the interval desired by the server.

fn present_user_code(&mut self, pi: &PollInformation)

The server has returned a user_code which must be shown to the user, 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.

fn present_user_url(&mut self, url: &String, need_code: bool) -> Option<String>

Only method currently used by the InstalledFlow. We need the user to navigate to a URL using their browser and potentially paste back a code (or maybe not). Whether they have to enter a code depends on the InstalledFlowReturnMethod used.

Loading content...

Implementors

impl AuthenticatorDelegate for DefaultAuthenticatorDelegate[src]

fn connection_error(&mut self, _: &Error) -> Retry[src]

fn token_storage_failure(&mut self, is_set: bool, _: &dyn Error) -> Retry[src]

fn request_failure(&mut self, _: RequestError)[src]

fn expired(&mut self, _: &DateTime<Utc>)[src]

fn denied(&mut self)[src]

fn token_refresh_failed(
    &mut self,
    error: &String,
    error_description: &Option<String>
)
[src]

fn pending(&mut self, _: &PollInformation) -> Retry[src]

fn present_user_code(&mut self, pi: &PollInformation)[src]

fn present_user_url(&mut self, url: &String, need_code: bool) -> Option<String>[src]

Loading content...