ServiceAccount

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

A Google Cloud credential: a service account key, or Application Default Credentials.

Throws

if serviceAccountCredential is null and useDefaultCredential is false, or if useIdToken is true and audience is null or empty.

Constructors

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

Types

Link copied to clipboard
class Builder

Fluent builder for ServiceAccount, provided primarily for Java callers. Any property left unset falls back to the same default as the constructor.

Link copied to clipboard
object Companion
Link copied to clipboard
data class Credential(val type: String = "", val projectId: String, val privateKeyId: Secret, val privateKey: Secret, val clientEmail: String, val clientId: String, val authUri: String, val tokenUri: String, val authProviderX509CertUrl: String, val clientX509CertUrl: String, val universeDomain: String)

A service account key, as in the JSON key file Google Cloud issues.

Properties

Link copied to clipboard

The audience of the ID token, usually the URL of the receiving service.

Link copied to clipboard

The OAuth2 scopes to request for the access token; pass at least one with a key. With Application Default Credentials, null or empty means https://www.googleapis.com/auth/cloud-platform. ID tokens ignore them.

Link copied to clipboard

The service account key; required unless useDefaultCredential is true.

Link copied to clipboard

Whether to use Application Default Credentials instead of a key.

Link copied to clipboard

Whether to get an ID token instead of an access token; requires a non-empty audience.

Functions

Link copied to clipboard

Returns a Builder initialized with this instance's properties, primarily for Java callers. Prefer it over copy from Java: copy takes every property positionally, so its signature changes whenever a property is added.