taolib.testing.oauth.services.token_service#
OAuth Token 服务模块。
管理 OAuth Token 的加密存储和自动刷新。
Attributes#
Classes#
OAuth Token 服务。 |
Module Contents#
- taolib.testing.oauth.services.token_service.REFRESH_BUFFER_MINUTES = 5#
- class taolib.testing.oauth.services.token_service.OAuthTokenService(token_encryptor: taolib.testing.oauth.crypto.token_encryption.TokenEncryptor, connection_repo: taolib.testing.oauth.repository.connection_repo.OAuthConnectionRepository, credential_repo: taolib.testing.oauth.repository.credential_repo.OAuthAppCredentialRepository, activity_repo: taolib.testing.oauth.repository.activity_repo.OAuthActivityLogRepository, provider_registry: taolib.testing.oauth.providers.ProviderRegistry)#
OAuth Token 服务。
处理 OAuth Token 的加密、解密和自动刷新。
- 参数:
token_encryptor -- Token 加密器
connection_repo -- 连接仓储
credential_repo -- 凭证仓储
activity_repo -- 活动日志仓储
provider_registry -- 提供商注册表
- _encryptor#
- _connection_repo#
- _credential_repo#
- _activity_repo#
- _provider_registry#
- decrypt_access_token(connection: taolib.testing.oauth.models.connection.OAuthConnectionDocument) str#
解密连接的 Access Token。
- 参数:
connection -- 连接文档
- 返回:
明文 Access Token
- async refresh_if_expired(connection: taolib.testing.oauth.models.connection.OAuthConnectionDocument) taolib.testing.oauth.models.connection.OAuthConnectionDocument#
如果 Token 即将过期则刷新。
在 Token 过期前 5 分钟主动刷新。
- 参数:
connection -- 连接文档
- 返回:
更新后的连接文档(如果刷新了)或原始文档