Skip to main content

OAuthProvider

Trait OAuthProvider 

Source
pub trait OAuthProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn login<'a>(
        &'a self,
        interaction: &'a Interaction,
        options: &'a LoginOptions,
    ) -> BoxFuture<'a, Result<OAuthCredential, AuthError>>;
    fn refresh<'a>(
        &'a self,
        credential: &'a OAuthCredential,
        cancel: &'a CancellationToken,
    ) -> BoxFuture<'a, Result<OAuthCredential, AuthError>>;

    // Provided methods
    fn login_label(&self) -> Option<&str> { ... }
    fn is_subscription(&self) -> bool { ... }
    fn to_auth<'a>(
        &'a self,
        credential: &'a OAuthCredential,
    ) -> BoxFuture<'a, Result<OAuthAuth, AuthError>> { ... }
}
Expand description

An account sign-in: log in, refresh, and derive request credentials.

Required Methods§

Source

fn name(&self) -> &str

Method name, such as Anthropic (Claude Pro/Max).

Source

fn login<'a>( &'a self, interaction: &'a Interaction, options: &'a LoginOptions, ) -> BoxFuture<'a, Result<OAuthCredential, AuthError>>

Runs the sign-in.

Source

fn refresh<'a>( &'a self, credential: &'a OAuthCredential, cancel: &'a CancellationToken, ) -> BoxFuture<'a, Result<OAuthCredential, AuthError>>

Exchanges the refresh token for a new credential.

Provided Methods§

Source

fn login_label(&self) -> Option<&str>

Label of the login menu entry, when the provider sets one.

Source

fn is_subscription(&self) -> bool

Whether the account is a subscription, which the login menu labels.

Source

fn to_auth<'a>( &'a self, credential: &'a OAuthCredential, ) -> BoxFuture<'a, Result<OAuthAuth, AuthError>>

Request credentials for a valid token.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§