Skip to content

AWS CLI v2.37.5 aws login returns 400 Bad Request during OAuth authorization despite successful Console login

0

Issue

I am experiencing a persistent HTTP 400 Bad Request when running aws login with an IAM user on Windows.

Normal AWS Management Console login works successfully with the same IAM user and MFA, but AWS CLI browser-based OAuth authorization fails before redirecting to the localhost callback.

Environment

  • AWS CLI: 2.37.5
  • OS: Windows 10, AMD64
  • Sign-In region: ap-southeast-1
  • Browser: Microsoft Edge
  • Authentication: IAM user with MFA
  • Credential approach: AWS CLI login without long-term access keys

Troubleshooting Already Completed

  1. Confirmed that the IAM user can successfully sign in to the AWS Management Console.
  2. Verified the required OAuth login actions and the region-specific IAM Resource ARN.
  3. Checked the IAM policy with IAM Access Analyzer; no findings were reported.
  4. Changed the OAuth login region from ap-southeast-5 to ap-southeast-1, which supports OAuth endpoints.
  5. Retried with a fresh Edge InPrivate window and a newly generated authorization link. The same 400 error occurred.
  6. Compared the local AWS CLI 2.37.5 OAuth request construction with the official AWS CLI source. No confirmed critical differences were found.
  7. Searched CloudTrail for the relevant Sign-In events but found no matching records in the regions checked.

The browser displays 400 Bad Request during the AWS Sign-In authorization process. The localhost callback is not reached.

Related Issue

This resembles AWS CLI GitHub issue #10186:

https://github.com/aws/aws-cli/issues/10186

Questions

  1. Is this a known AWS Sign-In service issue affecting the aws login OAuth authorization flow?
  2. Are there additional regional endpoint or IAM policy requirements that could cause this HTTP 400 response?
  3. What is the recommended diagnostic procedure to identify the rejection reason without exposing OAuth tokens, session cookies, or authorization URLs?
  4. Is there a supported workaround that preserves MFA and avoids long-term IAM access keys?

Any guidance from AWS engineers or community experts would be appreciated.

1 Answer
0
Accepted Answer

There's no confirmed AWS Sign-In service issue matching this. GitHub issue #10186 is still open, labelled bug, login, p2 and service-api, with no root cause or workaround posted. It describes the same symptom: a 400 shown in the browser and the localhost callback never reached. In that report, the trigger was stale console session cookies. Since you see the 400 even in a fresh InPrivate window, your case may have a different cause.

1. Is this a known issue?

Partly. Issue #10186 shows that the authorize endpoint returns a plain 400 to the browser instead of redirecting with an OAuth error parameter. As a result, the CLI only reports a timeout and the real reason is hidden. Nothing public covers your exact case (Windows, fresh session, ap-southeast-1).

2. Endpoint and permission checks

  • Region. Make sure the region in the profile used by aws login (aws configure get region) is the same as the host in the authorize URL (signin.ap-southeast-1.amazonaws.com), and that the resource ARN in your policy uses that same region. Also try us-east-1 to rule out a regional problem.
  • Permissions. As a baseline, attach the AWS managed policy SignInLocalDevelopmentAccess. If you use a custom policy, the resource for aws login must be arn:aws:signin:<region>:<account-id>:oauth2/public-client/localhost. The --remote flow uses .../oauth2/public-client/remote.
  • Policies Access Analyzer doesn't evaluate. Policy validation in Access Analyzer doesn't check SCPs, RCPs or permission boundaries. Check whether any of these deny signin:* or restrict regions with aws:RequestedRegion.

3. Diagnosing without exposing secrets

  • Browser DevTools (F12 → Network, with "Preserve log" on): reproduce the error and find the request that returns 400. Note only the host, path, status code and any error or error_description value in the response or redirect. Don't share cookies, code values or full URLs.
  • Missing URL parameters on Windows: on Windows, URLs launched through the shell are sometimes cut off at the first &, which would produce exactly this 400. Compare the URL in the Edge address bar with the one the CLI prints. Check that only the parameter names are all present: response_type, client_id, redirect_uri, code_challenge, code_challenge_method, state and so on. If any are missing, paste the full printed URL into the browser yourself.
  • Use --remote: run aws login --remote, which needs the remote resource ARN. It avoids the localhost redirect. If it works, the problem is the local callback, browser launch or redirect, not your identity or policy.
  • Isolate the cause: try another browser (Chrome or Firefox), another network (no corporate proxy or TLS inspection), and briefly another principal with admin rights.
  • aws login --debug: shows what the CLI builds and sends. Redact state, code_challenge and anything token-like before sharing.
  • CloudTrail: Sign-In events are often logged in us-east-1 as well as the sign-in region, so check both. A request rejected as malformed before authentication may not be logged at all, which would itself point to a malformed request rather than a permissions problem.

4. Workarounds that keep MFA and avoid long-term keys

  • aws login --remote: same mechanism, different redirect path.
  • IAM Identity Center (aws configure sso): this is AWS's recommended path for human CLI access. It enforces MFA and issues short-lived credentials, and it doesn't depend on the aws login flow.
  • AWS CloudShell: gives you a CLI from the console session immediately, using the console's MFA-backed credentials.

If none of this isolates the cause, open an AWS Support case for the Sign-In service. Include the CLI version, the region, the timestamp and the host and path of the 400 request from DevTools. You could also add a comment to #10186 noting that it reproduces in a fresh session on Windows.

Sources:

EXPERT

answered a month ago

  • Hi Takahiro,

    Thank you for your detailed and helpful explanation.

    I would like to investigate this issue more deeply and identify the actual failure point before changing any IAM permissions or security configuration.

    My environment and symptoms:

    • AWS CLI v2.37.5 on Windows
    • Region: ap-southeast-1
    • AWS Management Console login succeeds
    • aws login produces HTTP 400 Bad Request during browser-based OAuth authorization
    • The issue also occurs in a fresh Edge InPrivate session
    • The localhost OAuth callback is never reached
    • The AWS environment has strict IAM security controls, and any permission changes require separate approval

    I have seven follow-up questions.

    1. Exact OAuth failure stage

    How can we determine whether HTTP 400 originates from initial /authorize request validation, AWS Sign-In session handling, IAM authorization, or another part of the OAuth flow?

    Are there specific response headers, error codes, request IDs, or redirect patterns that distinguish these cases?

    2. IAM denial versus malformed OAuth request

    Can an explicit IAM Deny, permission boundary, or SCP cause the AWS Sign-In authorization endpoint to return HTTP 400 instead of 403 or an OAuth access_denied error?

    If so, what evidence would distinguish an IAM authorization failure from malformed OAuth parameters?

    3. Fresh browser session still fails

    Since the same HTTP 400 occurs in a new InPrivate browser session, what other known causes should we investigate besides sta

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.