Getting an IAM token for a federated account
Written by
Updated at November 27, 2024
Note
The IAM token lifetime cannot exceed 12 hours and is limited by the cookie lifetime for the federation.
CLI
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
-
Get an IAM token:
yc iam create-token
Specify the received IAM token when accessing Yandex Cloud resources via the API. Provide the IAM token in the Authorization
header in the following format:
Authorization: Bearer <IAM_token>
Examples
Using an IAM token obtained via the CLI
Save the IAM token to a variable in the CLI and use it in other requests from the command line. Sample request to get cloud list:
Bash
PowerShell
export IAM_TOKEN=`yc iam create-token`
curl \
--request GET \
--header "Authorization: Bearer ${IAM_TOKEN}" \
https://resource-manager.api.cloud.yandex.net/resource-manager/v1/clouds
$IAM_TOKEN=yc iam create-token
curl.exe `
--request GET `
--header "Authorization: Bearer $IAM_TOKEN" `
https://resource-manager.api.cloud.yandex.net/resource-manager/v1/clouds