Skip to main content

OAuthHandler

Trait OAuthHandler 

Source
pub trait OAuthHandler: Send + Sync {
    // Required methods
    fn redirect_uri(&self) -> &str;
    fn authorize(
        &self,
        auth_url: &str,
    ) -> BoxFuture<'_, Result<OAuthCallback, OAuthError>>;
}
Expand description

Trait that consuming applications implement to handle OAuth UI/UX.

Uses BoxFuture instead of async fn to support dyn OAuthHandler (required for Arc<dyn OAuthHandler> in McpManager).

Required Methods§

Source

fn redirect_uri(&self) -> &str

The redirect URI the OAuth provider should send the user back to, e.g. http://127.0.0.1:<port>/oauth2callback.

Source

fn authorize( &self, auth_url: &str, ) -> BoxFuture<'_, Result<OAuthCallback, OAuthError>>

Called when user needs to authorize. App should open browser to auth_url and return the authorization code and state (CSRF token) from the callback.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§