Bobcares

Error Loading SSO Token Expired in AWS: How to Resolve?

by | May 31, 2023

Let us learn how to resolve the error loading sso token expired in aws with the support of our AWS support services Bobcares.

Error: Error loading SSO token expired in AWS

If a user finds problems when performing Amazon CLI commands, they should make sure they are using the most recent AWS CLI version.

In order for temporary security credential requests to reach AWS endpoint.

nts, the user must sue.

To establish credentials for a position, you must use an access key ID, a secret access key, and a session token. The AWS endpoint must receive requests within five minutes of their timestamp, or it will reject them

Resolve Error: error loading sso token expired in AWS

Using Profiles to assume an IAM Role

A profile with a name is a set of settings and credentials that we can use with an AWS CLI command. We must ensure that we are utilizing the proper credentials.

We can use the default profile credentials in the following AWS CLI command:

aws s3 ls

This example command makes use of the project1 profile credentials set in the.config file:

aws s3 ls --profile project1

Using expired credentials as an example:

"An error occurred (ExpiredToken) when calling the ListBuckets operation: The provided token has expired."

The profiles are in the.aws folder, which also contains the.credentials and.config files.

For Linux/macOS, the config file is at ~/.aws/config and for Windows users it is at C:\Users\%USERPROFILE%\.aws\config.

To verify the default profile credentials, use the following command:

aws configure list --profile default

Example:

error loading sso token expired in aws

Run the following command to ensure that we use the same credentials for the profile project1.

aws configure list --profile project1

Example:

Name Value Type Location ---- ----- ---- -------- profile project1 manual —profile access_key QN2X config-file secret_key LPYI config-file region eu-west-1 config-file ~/.aws/config

Please keep in mind that the default and project1 profiles may have distinct credentials as shown in the example output.

In the .aws/config file, we may construct a profile in the following format:

[profile project1] region = eu-west-1 aws_access_key_id = access-Key-for-an-IAM-role aws_secret_access_key = secret-access-Key-for-an-IAM-role aws_session_token = session-token

These credentials are sent to us when we execute the AWS STS assume-role command, which looks like this:

aws sts assume-role --role-arn arn:aws:iam:::role/Prod-Role --role-session-name environment-prod

Example output:

{ "AssumedRoleUser": { "AssumedRoleId": "AROAXXXXXXXXXXXX:environment-prod", "Arn": "arn:aws:sts::account-number:assumed-role/Prod-Role/environment-prod" }, "Credentials": { "SecretAccessKey": "secret-access-Key-for-an-IAM-role, "SessionToken": "session-token", "Expiration": "2020-03-31T17:17:53Z", "AccessKeyId": "access-Key-for-an-IAM-role"}

Note: Using the DurationSeconds option for the use case, we may enhance the maximum session length expiry for temporary credentials for IAM roles.

Following that, the new assume-role API call receives a new set of valid credentials. We must manually update the /.aws/config file with the new temporary credentials after the API request.

We can avoid having to update the configuration file every time a session expires.

In the /.aws/config or /.aws/credentials file, provide a profile for the IAM role and the person who assumes the role, similar to this:

[profile project1] role_arn = arn-of-IAM-role source_profile = user1 region = region

It is worth noting that user1 is specified in the /.aws/credentials file in the following way:

[user1] aws_access_key_id=AKIAIOSFODNN7EXAMPLE aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

By specifying the source_profile, we avoid having to change the temporary credentials in the /.aws/config or /.aws/credentials files.

The AWS CLI command listed below lists the Amazon Simple Storage Service (Amazon S3) buckets with credentials for user1 in the /.aws/credentials file.

aws s3 ls --profile project1

Consider the AWS CLI with a source_profile attribute; the API call assume-role stores credentials in the.aws/cli/cache file.

In the.aws/cli/cache file, expired credentials are immediately updated. If we get an error about expired credentials, we may clear the cache using the commands:

Linux/macOS:

$ rm -r ~/.aws/cli/cache

Windows

C:\> del /s /q %UserProfile%\.aws\cli\cache

The AWS CLI will generate new credentials in cache.

Create environment variables to assume the IAM role and then verify access

We may utilize IAM role credentials to generate three environment variables to assume the IAM role, as shown below:

For Linux/macOS:

export AWS_ACCESS_KEY_ID=RoleAccessKeyID export AWS_SECRET_ACCESS_KEY=RoleSecretKey export AWS_SESSION_TOKEN=RoleSessionToken

For Windows:

C:\> setx AWS_ACCESS_KEY_ID RoleAccessKeyID C:\> setx AWS_SECRET_ACCESS_KEY RoleSecretKey C:\> setx AWS_SESSION_TOKEN RoleSessionToken

Run the following command to ensure that we have the right IAM role:

aws sts get-caller-identity

The get-caller-identity command returns details about the IAM identity that was used to authenticate the request.

Environment variables retain temporary cached credentials even after their expiration and lack automatic refreshing. To check if credential environment variables are set, execute the following commands.

Linux/macOS:

$ printenv | grep AWS

Windows:

C:\set AWS

The following commands can be used to delete expired environment variables:

For Linux/macOS:

$ unset AWS_ACCESS_KEY_ID
$ unset AWS_SECRET_ACCESS_KEY
$ unset AWS_SESSION_TOKEN

For Windows:

C:\set AWS_ACCESS_KEY_ID= C:\>set AWS_SECRET_ACCESS_KEY= C:\set AWS_SESSION_TOKEN=

We can now use the assume-role API request to obtain new, valid credentials and reset the environment variables.

[Need assistance with similar queries? We are here to help]

Conclusion

To sum up we have now seen how to resolve the error loading sso token expired in aws with the support of our tech support team.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF