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,
    ) -> Pin<Box<dyn Future<Output = Result<OAuthCallback, OAuthError>> + Send + '_>>;
}
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, ) -> Pin<Box<dyn Future<Output = Result<OAuthCallback, OAuthError>> + Send + '_>>

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.

Implementors§