Base¶
base
¶
OAuth provider base interface.
Defines the abstract interface for OAuth providers. All provider implementations (Google, GitHub, etc.) must inherit from OAuthProvider.
Classes¶
OAuthUserInfo
dataclass
¶
OAuthUserInfo(
provider_user_id: str,
email: str,
email_verified: bool,
name: str | None = None,
avatar_url: str | None = None,
)
User information returned from OAuth provider.
OAuthTokens
dataclass
¶
OAuthTokens(
access_token: str,
refresh_token: str | None = None,
expires_in: int | None = None,
token_type: str = "Bearer",
)
Tokens returned from OAuth provider.
OAuthProvider
¶
Bases: ABC
Abstract base class for OAuth providers.
Each provider (Google, GitHub, etc.) implements this interface.
Attributes¶
authorization_endpoint
abstractmethod
property
¶
OAuth authorization URL.
default_scopes
abstractmethod
property
¶
Default OAuth scopes (space-separated).
Functions¶
exchange_code_for_tokens
abstractmethod
async
¶
exchange_code_for_tokens(
*, code: str, redirect_uri: str, code_verifier: str | None = None
) -> OAuthTokens
Exchange authorization code for access/refresh tokens.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code |
str
|
Authorization code from callback |
required |
redirect_uri |
str
|
Redirect URI used in authorization |
required |
code_verifier |
str | None
|
Optional PKCE code verifier |
None
|
Returns:
| Type | Description |
|---|---|
OAuthTokens
|
OAuthTokens with access token and optional refresh token |
Source code in fastauth/providers/base.py
get_user_info
abstractmethod
async
¶
get_user_info(*, access_token: str) -> OAuthUserInfo
Fetch user information using access token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_token |
str
|
OAuth access token |
required |
Returns:
| Type | Description |
|---|---|
OAuthUserInfo
|
OAuthUserInfo with user profile data |
Source code in fastauth/providers/base.py
refresh_access_token
abstractmethod
async
¶
refresh_access_token(*, refresh_token: str) -> OAuthTokens
Refresh access token using refresh token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
refresh_token |
str
|
OAuth refresh token |
required |
Returns:
| Type | Description |
|---|---|
OAuthTokens
|
OAuthTokens with new access token |