clara.auth package
Submodules
clara.auth.google module
Google OAuth 2.0 Authorization and Token Exchange Routines.
This module provides routines to exchange authorization codes (such as Android serverAuthCode) for OAuth access and refresh tokens, and exposes FastAPI endpoints for mobile and web client authentication flows.
- class clara.auth.google.TokenExchangeRequest(*, serverAuthCode=None, code=None, clientId=None, clientSecret=None, redirectUri='')[source]
Bases:
BaseModelPayload schema for exchanging an authorization code.
- Parameters:
serverAuthCode (str | None)
code (str | None)
clientId (str | None)
clientSecret (str | None)
redirectUri (str | None)
- model_config = {'populate_by_name': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- clara.auth.google.exchange_server_auth_code(server_auth_code, client_id=None, client_secret=None, redirect_uri='')[source]
Exchanges a Google server auth code for access and refresh tokens.
- Parameters:
server_auth_code (str) – The authorization code received from the client.
client_id (Optional[str]) – OAuth 2.0 Client ID. Defaults to web client ID.
client_secret (Optional[str]) – OAuth 2.0 Client Secret. Defaults to web secret.
redirect_uri (str) – Authorized redirect URI, or empty string for Android.
- Returns:
- Result dictionary containing access_token, refresh_token,
expires_in, and token_type on success, or error details on failure.
- Return type:
Dict[str, Any]
- async clara.auth.google.exchange_google_auth_code_endpoint(payload=Body(PydanticUndefined))[source]
Endpoint for exchanging Google OAuth authorization code for tokens.
Supports inputs with server_auth_code, serverAuthCode, or code.
- Parameters:
payload (Dict[str, Any]) – Incoming JSON request payload.
- Returns:
Token dictionary or error response.
- Return type:
Dict[str, Any]
- Raises:
HTTPException – If server_auth_code is missing or exchange fails.
Module contents
Authentication and Authorization Module for Clara Core.
Provides OAuth 2.0 exchange routines and session management helpers.