taolib.testing.oauth.providers.google#
Google OAuth 提供商实现模块。
实现 Google OAuth2 + OpenID Connect 流程。
Attributes#
Classes#
Google OAuth 提供商。 |
Module Contents#
- taolib.testing.oauth.providers.google.GOOGLE_AUTH_URL = 'https://accounts.google.com/o/oauth2/v2/auth'#
- taolib.testing.oauth.providers.google.GOOGLE_TOKEN_URL = 'https://oauth2.googleapis.com/token'#
- taolib.testing.oauth.providers.google.GOOGLE_USERINFO_URL = 'https://www.googleapis.com/oauth2/v2/userinfo'#
- taolib.testing.oauth.providers.google.GOOGLE_REVOKE_URL = 'https://oauth2.googleapis.com/revoke'#
- taolib.testing.oauth.providers.google.GOOGLE_DEFAULT_SCOPES = ['openid', 'email', 'profile']#
- taolib.testing.oauth.providers.google.HTTP_TIMEOUT = 10.0#
- class taolib.testing.oauth.providers.google.GoogleOAuthProvider#
Google OAuth 提供商。
- get_authorize_url(client_id: str, redirect_uri: str, state: str, scopes: list[str]) str#
生成 Google 授权 URL。
- 参数:
client_id -- Google Client ID
redirect_uri -- 回调 URI
state -- CSRF 防护 state 参数
scopes -- 请求的权限范围
- 返回:
完整的 Google 授权 URL
- async exchange_code(code: str, client_id: str, client_secret: str, redirect_uri: str) dict[str, Any]#
用授权码交换 Google Token。
- 参数:
code -- 授权码
client_id -- Google Client ID
client_secret -- Google Client Secret
redirect_uri -- 回调 URI
- 返回:
Token 响应字典
- 抛出:
OAuthCodeExchangeError -- 交换失败
- async fetch_user_info(access_token: str) taolib.testing.oauth.models.profile.OAuthUserInfo#
获取 Google 用户信息。
- 参数:
access_token -- Google Access Token
- 返回:
标准化的用户信息
- 抛出:
OAuthUserInfoError -- 获取失败