common-fate / granted

The easiest way to access your cloud.
https://granted.dev
MIT License
1.12k stars 101 forks source link

`granted sso generate` only works when `--sso-region` is specified #385

Open alexjurkiewicz opened 1 year ago

alexjurkiewicz commented 1 year ago

Using granted 0.9.0

$ granted sso generate https://mycompany.awsapps.com/start/
[!] Please specify the --sso-region flag: 'granted generate --sso-region us-east-1 https://lightspeedhq.awsapps.com/start/'
[!] Currently, Granted defaults to using us-east-1 if this is not provided. In a future version, this flag will be required (https://github.com/common-fate/granted/issues/360)
[i] If the browser does not open automatically, please open this link: https://device.sso.us-east-1.amazonaws.com/?user_code=PKZJ-PHML
[i] Awaiting AWS authentication in the browser
[i] You will be prompted to authenticate with AWS in the browser, then you will be prompted to 'Allow'

Opens the following URL (after redirects) (replaced some fields with XXX):

https://mycompany.awsapps.com/start/user-consent/authorize.html?
clientId=XXX
&clientType=XXX
&deviceContextId=XXX
&region=us-west-2
&state=XXX

With content:

Authorize request

An application or device requested authorization using your AWS sign-in.
[Allow]
[Cancel]

Clicking Allow gives the following error popup:

invalid_grant

Invalid grant provided

The CLI doesn't react.

alexjurkiewicz commented 1 year ago

Issue persists in 0.9.1

alexjurkiewicz commented 1 year ago

Works when I specify --sso-region us-west-2! I'll retitle the issue