'AWS2 SSO Configuration error after installing aws2 cli on MacOS

For MacOS user who is installing the AWS CLI v2 and attempting to use with AWS SSO, you might see "An error occurred (InvalidClientException) when calling the StartDeviceAuthorization operation:"

If so, the solution is below.



Solution 1:[1]

For those who have install aws2 and having trouble with SSO cli, ensure that after you've installed the aws2, remove the sso directory in your ~/.aws directory and re-rerun aws2 configure sso. If not, that will return "An error occurred (InvalidClientException) when calling the StartDeviceAuthorization operation:"

And also, ensure your ~/.aws/config file looks like this

[profile default]
sso_start_url = https://someurlhere.awsapps.com/start
sso_region = us-east-2
sso_account_id = XXXXXXX
sso_role_name = AAAAA
region = us-east-2
output = json

Solution 2:[2]

You need to ingress the URL with "start"

Example: https://alias.awsapps.com/start

enter image description here

Solution 3:[3]

Make sure that the properties of your profile defined in ~/.aws/config don't have any comments similar to the example below.

[profile my-sso-prod]
sso_start_url = https://my-sso.awsapps.com/start # don't forget the /start part!

When I removed the text after (and including) #, everything worked.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lee.Tan
Solution 2 Roberto Carlos Reyes Fernandez
Solution 3 esimonov