Google¶
google
¶
Google OAuth provider implementation.
Provides Google OAuth 2.0 authentication using authorization code flow with PKCE support.
Classes¶
GoogleOAuthProvider
¶
Bases: OAuthProvider
Google OAuth 2.0 provider implementation.
Uses Google's OAuth 2.0 endpoints for authorization code flow. Supports PKCE and refresh tokens.
Initialize Google OAuth provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client_id |
str
|
Google OAuth client ID |
required |
client_secret |
str
|
Google OAuth client secret |
required |
Source code in fastauth/providers/google.py
Attributes¶
Functions¶
exchange_code_for_tokens
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 |
Raises:
| Type | Description |
|---|---|
HTTPError
|
If token exchange fails |
Source code in fastauth/providers/google.py
get_user_info
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 |
Raises:
| Type | Description |
|---|---|
HTTPError
|
If user info fetch fails |
Source code in fastauth/providers/google.py
refresh_access_token
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 |
Raises:
| Type | Description |
|---|---|
HTTPError
|
If token refresh fails |