Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR - Token must be six digits #36

Open
spanktar opened this issue Oct 15, 2018 · 3 comments
Open

ERROR - Token must be six digits #36

spanktar opened this issue Oct 15, 2018 · 3 comments

Comments

@spanktar
Copy link

spanktar commented Oct 15, 2018

I am receiving the error message:
ERROR - Token must be six digits

when using the command:

aws-mfa --duration 60 --profile default
INFO - Validating credentials for profile: default
INFO - Your credentials have expired, renewing.
Enter AWS MFA code for device [arn:aws:iam::1234567890:mfa/tom] (renewing for 60 seconds):123456
INFO - Fetching Credentials - Profile: default, Duration: 60
ERROR - Token must be six digits

Since clearly my MFA token is 6 digits, and since this had worked for me before, I got suspicious and started to change the duration value:

aws-mfa --duration 100 --profile default
ERROR - Token must be six digits
aws-mfa --duration 1000 --profile default
INFO - Success! Your credentials will expire in 1000 seconds at: 2018-10-15 17:13:02+00:00

So it appears the duration value being less than 4 digits is causing this error. I'll try to look at the code and submit a PR with a fix.

@albertofem
Copy link

Actually, the issue is that DurationSeconds in STS must be greater or equal than 900:

The duration, in seconds, that the credentials should remain valid. Acceptable durations for IAM user sessions range from 900 seconds (15 minutes) to 129,600 seconds (36 hours), with 43,200 seconds (12 hours) as the default. Sessions for AWS account owners are restricted to a maximum of 3,600 seconds (one hour). If the duration is longer than one hour, the session for AWS account owners defaults to one hour.

Source: https://docs.aws.amazon.com/STS/latest/APIReference/API_GetSessionToken.html

Rerunning this command with 900 should work. aws-mfa should surface this error properly.

martina-if added a commit to martina-if/aws-mfa that referenced this issue Jun 14, 2019
closes broamski#36 

When using a session duration of less than 900 seconds aws-mfa prints a misleading error message "Token must be six digits".

This PR prints the actual error. In the case of an invalid duration it will print the following:

```
INFO - Fetching Credentials - Profile: <profile>, Duration: 800
ERROR - Invalid parameter: Parameter validation failed:
Invalid range for parameter DurationSeconds, value: 800, valid range: 900-inf
```
@npearson72
Copy link

I'm getting the same error with a greater duration:

INFO - Validating credentials for profile: default
WARNING - Your existing credentials are missing or invalid, obtaining new credentials.
Enter AWS MFA code for device [<my mfa device>] (renewing for 4600 seconds):
INFO - Fetching Credentials - Profile: default, Duration: 4600
ERROR - Token must be six digits

My ~/.aws/credentials looks like:

[default-long-term]
aws_access_key_id = <my aws access key id>
aws_secret_access_key = <my aws secret access key>

[default]
aws_access_key_id = <my aws access key id>
aws_secret_access_key = <my aws secret access key>

@arealmaas
Copy link

@npearson72 Did you find a solution for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants