[Yandex Cloud documentation](../../../index.md) > [Yandex Identity and Access Management](../../index.md) > [Step-by-step guides](../index.md) > Authentication > IAM tokens > Getting an IAM token for a local user account

# Getting an IAM token for a local user account

{% note info %}

The [IAM token](../../concepts/authorization/iam-token.md) lifetime cannot exceed 12 hours and is limited by the cookie lifetime for the [user pool](../../../organization/concepts/user-pools.md).

{% endnote %}

{% list tabs group=instructions %}

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  1. [Authenticate in the CLI as a local user](../../../cli/operations/authentication/local-user.md).

  1. Get an IAM token:

      ```bash
      yc iam create-token
      ```

      Result:

      ```text
      t1.9euelZrLop7Uz8up********
      ```

      The value you get is an IAM token. You can copy it, save it to a file, or write it into a variable:

      ```bash
      export IAM_TOKEN=`<IAM_token>`
      ```

{% endlist %}

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:

```yaml
Authorization: Bearer <IAM_token>
```

If you have saved your IAM token to a variable, use the latter:

```yaml
Authorization: Bearer ${IAM_TOKEN}
```

## Examples {#examples}

### Using an IAM token obtained via the CLI {#use-cli}

Sending a request to get a list of clouds using an IAM token:

{% list tabs group=programming_language %}
   
- Bash {#bash}

  1. Get an IAM token and write it to the variable:

     ```bash
     export IAM_TOKEN=`yc iam create-token`
     ```

  1. Send a request to get a list of clouds:

     ```bash
     curl \
       --request GET \
       --header "Authorization: Bearer ${IAM_TOKEN}" \
       https://resource-manager.api.cloud.yandex.net/resource-manager/v1/clouds
     ```

  1. Result:
   
     ```bash
     {
     "clouds": [
       {
       "id": "b1gia87mbaom********",
       "createdAt": "2019-08-19T06:15:54Z",
       "name": "my-cloud-1",
       "organizationId": "my-organization"
       },
       {
       "id": "b1gue7m154kt********",
       "createdAt": "2022-08-29T13:27:03Z",
       "name": "my-cloud-2",
       "organizationId": "my-organization"
       }
     ]
     }
     ```

- PowerShell {#powershell}

  1. Get an IAM token and write it to the variable:

     ```powershell
     $IAM_TOKEN=yc iam create-token
     ```

  1. Send a request to get a list of clouds:

     ```powershell
     curl.exe ` 
       --request GET ` 
       --header "Authorization: Bearer $IAM_TOKEN" ` 
       https://resource-manager.api.cloud.yandex.net/resource-manager/v1/clouds 
     ```

  1. Result:

     ```powershell
     {
     "clouds": [
       {
       "id": "b1gia87mbaom********",
       "createdAt": "2019-08-19T06:15:54Z",
       "name": "my-cloud-1",
       "organizationId": "my-organization"
       },
       {
       "id": "b1gue7m154kt********",
       "createdAt": "2022-08-29T13:27:03Z",
       "name": "my-cloud-2",
       "organizationId": "my-organization"
       }
     ]
     }
     ``` 
   
{% endlist %}

#### See also {#see-also}

* [Revoking an IAM token](revoke-iam-token.md)