OAuth 模块
exception TIPCommon.oauth.AuthenticationError
基类:Exception
身份验证错误的通用异常。
class TIPCommon.oauth.AuthorizedOauthClient
类 TIPCommon.oauth.AuthorizedOauthClient(oauth_manager: OauthManager, *args, **kwargs)
基类:Client
此类表示用于 API 调用的已获授权的客户端。
方法
保存令牌并关闭客户端会话。
覆盖以支持自动凭据刷新。该方法会在执行请求之前检查凭据是否已过期,并验证响应以检查是否指示凭据已过期。如果需要,它会使用刷新后的令牌再次执行请求。
类 TIPCommon.oauth.CredStorage
类 TIPCommon.oauth.CredStorage(encryption_password: str, chronicle_soar: SiemplifyAction | SiemplifyConnectorExecution | SiemplifyJob)
代码库:对象
管理凭据的存储和检索。
方法
get_instance_identifier()→ str获取连接器或集成的 Google SecOps 实例标识符。get_token()→ OauthToken | None从上下文数据库中提取并解密令牌。set_token(token: OauthToken)→ None加密令牌并将其保存到上下文数据库中。
exception TIPCommon.oauth.EncryptionError
基类:Exception
加密错误的通用异常。
类 TIPCommon.oauth.OAuthAdapter
基类:ABC
一个抽象基类,用于定义 OAuth 操作的接口。
抽象方法
abstractcheck_signer(token: OauthToken)→ bool如果签名者有效,则返回True;否则返回False。为授权客户端设置标头或其他必要的客户端配置。
abstractrefresh_token()→ OauthToken刷新令牌并返回OauthToken数据模型。abstract static validate_bad_credentials(response: Response)→ bool检查响应是否指示凭据已过期。
可能引发的错误
AuthenticationError - 当响应表明凭据已过期时。
类 TIPCommon.oauth.OauthManager
类 TIPCommon.oauth.OauthManager(oauth_adapter: OAuthAdapter, cred_storage: CredStorage)
代码库:对象
管理 OAuth 身份验证流程,包括令牌刷新和客户端准备。
方法
准备已获授权的客户端以供使用。
refresh_if_bad_credentials(auth_client: AuthorizedOauthClient, response: Response)→ bool如果响应表明凭据无效,则刷新令牌。refresh_if_expired(auth_client: AuthorizedOauthClient)→ bool如果令牌已过期,则刷新令牌。save_token()→ None保存当前令牌。
类 TIPCommon.oauth.OauthToken
类 TIPCommon.oauth.OauthToken(access_token: 'str', expiration_time: 'int', refresh_token: 'str' = None, signer: 'str' = None, additional_data: 'SingleJson' = <factory>)
代码库:对象
表示 OAuth 令牌及其关联的数据。
属性
| 属性 | 说明 |
|---|---|
access_token |
str访问令牌字符串。 |
additional_data |
MutableMapping[str, Any]与令牌关联的其他数据。 |
expiration_time |
int令牌到期时间(Unix 时间戳)。 |
refresh_token |
str刷新令牌字符串。 默认值为 |
signer |
str令牌的签署者。 默认值为 |
方法
to_cache()→ JsonString将OauthToken对象序列化为适合缓存的格式。
classmethod from_cache
classmethod from_cache(raw_data: JsonString)→ OauthToken
根据原始缓存数据创建 OauthToken 对象。
需要更多帮助?获得社区成员和 Google SecOps 专业人士的解答。