Skip to content

400 - Bad Request when logging in using AWS CLI

0

I am trying to sign-in using the AWS CLI and I'm getting a 400 - Bad Request error. I've updated my awscli package to the latest version. I am able to login to the console manually via the browser by navigating to the sign in page, but not when using the link from the awscli. When I run the command aws login, it takes me to a browser page. When I input my credentials (same credentials I use to login manually by navigating) I get 400 - Bad Request.

asked 6 months ago886 views
3 Answers
0
Accepted Answer

It turns out the issue was that the SignInLocalDevelopmentAccess policy was disabled for my group. Enabling it allowed me to sign in and the issue is resolved.

answered 6 months ago
0

It sounds like you're experiencing an issue with the AWS CLI authentication process. This problem could be occurring for several reasons:

  1. Credential Configuration Issues: There might be a mismatch between your configured credentials and the authentication method you're trying to use. The "400 - Bad Request" error often indicates that something in the authentication request is malformed or invalid.

  2. SSO vs. IAM User Credentials: Your error suggests you might be mixing authentication methods. If your organization uses IAM Identity Center (formerly AWS SSO), but you've configured the CLI with IAM user credentials (or vice versa), this can cause authentication failures.

  3. Expired or Invalid Tokens: If you're using SSO authentication, your tokens may have expired. The CLI attempts to refresh these tokens automatically, but sometimes this process fails.

  4. Browser Session Issues: Since the authentication is happening through a browser, there could be issues with cookies, cache, or session data interfering with the process.

Here are some steps to troubleshoot and resolve this issue:

  1. Clear Browser Cache: Try clearing your browser's cookies and cache, or use an incognito/private browsing window when the CLI opens the authentication page.

  2. Check Configuration: Run aws configure list to verify what credentials and region are actually being used by your CLI.

  3. Delete AWS Credentials Folder: If you suspect there might be conflicting or corrupted credential files, try deleting the .aws folder from your user home directory and reconfigure your credentials.

  4. Verify Authentication Method: Ensure you're using the correct authentication method for your account setup. If you're using SSO, you should configure the CLI with aws configure sso rather than just aws configure.

  5. Check Time Synchronization: Ensure your system clock is accurately synchronized, as AWS authentication is time-sensitive.

If these steps don't resolve the issue, you might need to contact AWS Support for further assistance, as there could be an account-specific problem that requires their intervention.
Sources
Problem with credentials when working with AWS CLI commands | AWS re:Post
Why doesn't my AWS CLI work? | AWS re:Post

answered 6 months ago
EXPERT
reviewed 6 months ago
0

You can also try logging in private or incognito mode and retry. Also, if you have setup profiles, make sure you use the profile in your login command.

EXPERT
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.