- [HTTP request](https://docs.cloud.google.com/workstations/docs/reference/rest/v1/projects.locations.workstationClusters.workstationConfigs.workstations/generateAccessToken#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/workstations/docs/reference/rest/v1/projects.locations.workstationClusters.workstationConfigs.workstations/generateAccessToken#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/workstations/docs/reference/rest/v1/projects.locations.workstationClusters.workstationConfigs.workstations/generateAccessToken#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/workstations/docs/reference/rest/v1/projects.locations.workstationClusters.workstationConfigs.workstations/generateAccessToken#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/workstations/docs/reference/rest/v1/projects.locations.workstationClusters.workstationConfigs.workstations/generateAccessToken#body.response_body)
  - [JSON representation](https://docs.cloud.google.com/workstations/docs/reference/rest/v1/projects.locations.workstationClusters.workstationConfigs.workstations/generateAccessToken#body.GenerateAccessTokenResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://docs.cloud.google.com/workstations/docs/reference/rest/v1/projects.locations.workstationClusters.workstationConfigs.workstations/generateAccessToken#body.aspect)
- [Try it!](https://docs.cloud.google.com/workstations/docs/reference/rest/v1/projects.locations.workstationClusters.workstationConfigs.workstations/generateAccessToken#try-it)

Returns a short-lived credential that can be used to send authenticated and authorized traffic to a workstation. Once generated this token cannot be revoked and is good for the lifetime of the token.

### HTTP request

Choose an endpoint:
global asia-south1 europe-west6 us-central1 us-east1 us-east4 us-east5 us-west1 us-west4   
`POST https://workstations.googleapis.com/v1/{workstation=projects/*/locations/*/workstationClusters/*/workstationConfigs/*/workstations/*}:generateAccessToken`

<br />

The URLs use [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `workstation` | `string` Required. Name of the workstation for which the access token should be generated. |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "port": integer, // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "expireTime": string, "ttl": string // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `port` | `integer` Optional. Port for which the access token should be generated. If specified, the generated access token grants access only to the specified port of the workstation. If specified, values must be within the range \[1 - 65535\]. If not specified, the generated access token grants access to all ports of the workstation. |
| Desired expiration or lifetime of the access token. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `expireTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Desired expiration time of the access token. This value must be at most 24 hours in the future. If a value is not specified, the token's expiration time will be set to a default value of 1 hour in the future. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `ttl` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#duration` format)`` Desired lifetime duration of the access token. This value must be at most 24 hours. 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 '`s`'. Example: `"3.5s"`. |
| End of mutually exclusive fields. ||

### Response body

Response message for workstations.generateAccessToken.

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "accessToken": string, "expireTime": string } ``` |

| Fields ||
|---|---|
| `accessToken` | `string` The generated bearer access token. To use this token, include it in an Authorization header of an HTTP request sent to the associated workstation's hostname---for example, `Authorization: Bearer <accessToken>`. |
| `expireTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Time at which the generated token will expire. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |

### Authorization scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).