Generates an OAuth 2.0 access token for a service account.
HTTP request
POST https://iamcredentials.googleapis.com/v1/{name=projects/*/serviceAccounts/*}:generateAccessToken
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
name |
Required. The resource name of the service account for which the credentials are requested, in the following format: Authorization requires the following IAM permission on the specified resource
|
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "delegates": [ string ], "scope": [ string ], "lifetime": string } |
Fields | |
---|---|
delegates[] |
The sequence of service accounts in a delegation chain. This field is required for delegated requests. For direct requests, which are more common, do not specify this field. Each service account must be granted the The delegates must have the following format: |
scope[] |
Required. Code to identify the scopes to be included in the OAuth 2.0 access token. See https://developers.google.com/identity/protocols/googlescopes for more information. At least one value required. |
lifetime |
The desired lifetime duration of the access token in seconds. By default, the maximum allowed value is 1 hour. To set a lifetime of up to 12 hours, you can add the service account as an allowed value in an Organization Policy that enforces the If a value is not specified, the token's lifetime will be set to a default value of 1 hour. A duration in seconds with up to nine fractional digits, ending with ' |
Response body
If successful, the response body contains data with the following structure:
JSON representation |
---|
{ "accessToken": string, "expireTime": string } |
Fields | |
---|---|
accessToken |
The OAuth 2.0 access token. |
expireTime |
Token expiration time. The expiration time is always set. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: |
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/iam
https://www.googleapis.com/auth/cloud-platform
For more information, see the Authentication Overview.