Auth凭据(Credential)

A credential that a tool uses to call a service: an ApiKey, an Http credential, an OAuth2 or OpenID Connect credential, or a ServiceAccount.

Secret fields are Secrets, so a credential's toString() prints them as <redacted>. OAuth2 also redacts its state, nonce, authUri and redirectUri, which are plain strings.

Inheritors

类型

Link copied to clipboard
data class ApiKey(val apiKey: Secret? = null) : AuthCredential

一个 API 密钥;该工具会根据服务的认证机制(例如在请求头中)将此密钥发送到相应的位置。

Link copied to clipboard
data class Http(val scheme: String, val credentials: AuthCredential.Http.Credentials, val additionalHeaders: Map<String, Secret>? = null) : AuthCredential

一种 HTTP 认证凭据,通常会通过某种方式(如请求头或请求体)被发送到服务器。 Authorization header.

Link copied to clipboard
data class OAuth2(val variant: AuthCredential.OAuth2.Variant = Variant.OAUTH2, val clientId: String? = null, val clientSecret: Secret? = null, val authUri: String? = null, val nonce: String? = null, val state: String? = null, val redirectUri: String? = null, val authResponseUri: Secret? = null, val authCode: Secret? = null, val accessToken: Secret? = null, val refreshToken: Secret? = null, val idToken: Secret? = null, val expiresAt: Instant? = null, val expiresIn: Duration? = null, val audience: String? = null, val prompt: String? = null, val codeVerifier: Secret? = null, val codeChallengeMethod: String? = null, val tokenEndpointAuthMethod: AuthCredential.OAuth2.TokenEndpointAuthMethod? = TokenEndpointAuthMethod.CLIENT_SECRET_BASIC) : AuthCredential

一个 OAuth2 或 OpenID Connect 凭据:包括客户端的配置信息、用户的登录状态,以及用户登录后生成的令牌(tokens)。

Link copied to clipboard
data class ServiceAccount(val serviceAccountCredential: AuthCredential.ServiceAccount.Credential? = null, val scopes: List<String>? = null, val useDefaultCredential: Boolean = false, val useIdToken: Boolean = false, val audience: String? = null) : AuthCredential

一个 Google Cloud 凭据:可以是服务账户密钥(Service Account Key),也可以是应用程序默认凭据(Application Default Credentials)。