Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dvlpjrs/guMCP/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The OAuth utilities module provides generic, reusable functions for handling OAuth 2.0 authentication flows, token refresh, and PKCE (Proof Key for Code Exchange) operations. Source:src/utils/oauth/util.py
Core Functions
run_oauth_flow
Generic OAuth flow handler that can be used by different services. Source:src/utils/oauth/util.py:84
Name of the service (e.g., “microsoft”, “slack”)
ID of the user authenticating
List of OAuth scopes to request
Base authorization URL for the service
Token exchange URL for the service
Function to build auth URL parameters. Signature:
(oauth_config, redirect_uri, scopes) -> Dict[str, str]Function to build token request data. Signature:
(oauth_config, redirect_uri, scopes, auth_code) -> Dict[str, str]Optional function to process token response. Signature:
(token_response) -> Dict[str, Any]Optional function to build token request headers. Signature:
(oauth_config) -> Dict[str, str]Port to use for local callback server
Dictionary containing the OAuth credentials including access_token, refresh_token, and expires_at
- Gets OAuth config from auth client
- Starts local HTTP server for callback
- Opens browser for user authorization
- Waits for callback (120 second timeout)
- Exchanges authorization code for tokens
- Saves credentials using auth client
refresh_token_if_needed
Checks if token needs refresh and handles the refresh process. Source:src/utils/oauth/util.py:210
ID of the user
Name of the service
URL for token refresh
Function to build token refresh request data. Signature:
(oauth_config, refresh_token, credentials_data) -> Dict[str, str]Optional function to process token response
Optional function to build token request headers
Optional API key for auth client
If True, returns full credentials dict; if False, returns only access_token
Access token string if
return_full_credentials=False, otherwise full credentials dictionary- Gets credentials from auth client
- Checks if token has expired or will expire in 5 minutes
- Refreshes token if needed (only in local environment)
- Saves updated credentials
- Returns access token or full credentials
generate_code_verifier
Generates a code verifier for PKCE. Source:src/utils/oauth/util.py:319
Cryptographically secure random string of 64 characters using a-z, A-Z, 0-9, ”.”, ”-”, and ”_“
generate_code_challenge
Generates a code challenge from the code verifier. Source:src/utils/oauth/util.py:331
The code verifier string
Base64 URL-encoded SHA-256 hash of the code verifier with padding removed
OAuthCallbackHandler
HTTP request handler for OAuth callback. Source:src/utils/oauth/util.py:22
do_GET
Handles GET requests with OAuth callback. Source:src/utils/oauth/util.py:25
- Parses query parameters from callback URL
- Extracts authorization code or error
- Parses state parameter for code_verifier (PKCE)
- Stores additional parameters from callback
- Returns HTML page with success/error message
Example Usage
Basic OAuth Flow
Token Refresh
PKCE Flow
Error Handling
See Also
- Service Helper Utilities - Service-specific OAuth implementations
- BaseAuthClient - Authentication client interface
- create_auth_client() - Auth client factory