# ExpiredToken: The security token included in the request is expired

AWS error fixes · Updated 16 November 2026

**Short answer:** Your request was signed with temporary credentials whose expiry time has passed. Get fresh ones: run aws sso login for an SSO profile, re-run the assume-role step for role credentials, or unset stale AWS_SESSION_TOKEN variables so the SDK can fetch and refresh credentials itself.

## What the error means

Temporary credentials (access keys starting `ASIA`, plus a session token) carry an expiry time. Once it passes, every service rejects them:

```
An error occurred (ExpiredToken) when calling the ListObjectsV2 operation: The provided token has expired.
An error occurred (ExpiredTokenException) when calling the DescribeTable operation: The security token included in the request is expired
```

Nothing is wrong with your permissions. The identity was valid an hour ago; it simply needs new credentials. The real question is why nothing refreshed them.

## Why the credentials were not refreshed

| Where the credentials came from | Why they went stale |
|---|---|
| Values pasted or exported into the shell (`export AWS_SESSION_TOKEN=…`) | Nothing can refresh environment variables. They die at the session's expiry, often one hour. |
| IAM Identity Center (SSO) profile | The role credentials and the SSO sign-in session both expire; once the sign-in session ends, a new `aws sso login` is required. |
| Manual `aws sts assume-role` output | Default session is one hour; role chaining (assuming a role from a role) is capped at one hour regardless of the role's maximum. |
| A long-running process that copied credentials at start-up | Your code read keys once and passed them to a client, bypassing the SDK's refreshing provider. |
| A large `aws s3 cp` or `sync` using pasted credentials | The transfer outlived the token and fails partway through. |

## How to fix it

1. **Check what you're using.** If `aws configure list` shows `env` as the type, the expired values are in your shell.

   ```
   aws configure list
   unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
   ```

2. **SSO profile:** sign in again, then retry.

   ```
   aws sso login --profile prod-admin
   aws sts get-caller-identity --profile prod-admin
   ```

3. **Assumed role:** let the CLI do the assuming so it refreshes automatically. Define a profile instead of exporting keys:

   ```
   [profile prod-deploy]
   role_arn = arn:aws:iam::123456789012:role/Deploy
   source_profile = default
   duration_seconds = 3600
   ```

   Then `aws s3 ls --profile prod-deploy` assumes and refreshes the role on demand. See [switching roles in the CLI](https://cloudconsole.dev/how-to/switch-role-aws-cli).

4. **Need longer sessions?** Raise the role's maximum session duration (up to 12 hours), then request it with `duration_seconds`. This does not help with role chaining, which stays at one hour.

## In applications and pipelines

- Create SDK clients from the default credential chain instead of passing `aws_access_key_id`/`aws_session_token` explicitly. The chain re-reads instance, task and container credentials before they expire.
- On EC2, ECS and Lambda, never copy role credentials into a config file or environment variable; that freezes them.
- For CI jobs that assume a role through OIDC, request a session at least as long as the slowest job, and split very long jobs into stages that each get fresh credentials.
- Tools that call `aws configure export-credentials` to hand keys to another program get a snapshot; re-run it when the program is long-lived.

## Mistakes to avoid

Don't respond by creating long-term access keys "so it stops expiring". That trades a nuisance for a leaked-key risk. Also don't only raise the role's maximum duration without checking the request: the CLI and SDKs default to one hour unless you ask for more, so the change appears to do nothing.

If `aws sso login` itself fails with a refresh error, that is a separate problem with the cached SSO token; see [SSO token has expired and refresh failed](https://cloudconsole.dev/errors/sso-token-expired-refresh-failed).

## Questions

### How long do AWS temporary credentials last?

It depends on how they were issued. AssumeRole defaults to one hour and can go up to the role's maximum session duration (12 hours at most); role chaining is limited to one hour; SSO role credentials follow the permission set's session duration.

### Why does the AWS CLI say the SSO token has expired?

Your IAM Identity Center sign-in session has ended. Run aws sso login --profile <name> to start a new one; the CLI then fetches fresh role credentials automatically.

### Why does aws s3 fail with ExpiredToken halfway through a copy?

The transfer is using fixed temporary credentials, usually exported in the shell, and it ran past their expiry. Use a profile with role_arn or an SSO profile so the CLI can refresh them, or request a longer session.

## When this happens away from your desk

Expired credentials are a laptop problem rather than a production one, but they often block you at the worst moment of an incident. CloudConsole, a phone app for AWS, is built so you can still read alarms, logs and resource state from your phone while your terminal session is being renewed.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Recommended alarms (Amazon CloudWatch User Guide)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html)
- [Use temporary credentials with AWS resources](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html)
- [Use an IAM role in the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html)

## Related

- [Error when retrieving token from sso: Token has expired and refresh failed](https://cloudconsole.dev/errors/sso-token-expired-refresh-failed)
- [How to log in to AWS SSO from the CLI](https://cloudconsole.dev/how-to/aws-sso-login-cli)
- [How to switch role with the AWS CLI](https://cloudconsole.dev/how-to/switch-role-aws-cli)
- [aws sts assume-role](https://cloudconsole.dev/cli/sts-assume-role)
- [aws configure export-credentials](https://cloudconsole.dev/cli/configure-export-credentials)
- [The security token included in the request is invalid](https://cloudconsole.dev/errors/security-token-included-in-the-request-is-invalid)

---

Source: https://cloudconsole.dev/errors/expiredtoken

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
