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

[V2] Overriding/Suppressing default browser for 'configure sso' #4715

Closed
deejvince opened this issue Nov 28, 2019 · 10 comments
Closed

[V2] Overriding/Suppressing default browser for 'configure sso' #4715

deejvince opened this issue Nov 28, 2019 · 10 comments
Labels
feature-request A feature should be added or improved. p2 This is a standard priority issue sso v2

Comments

@deejvince
Copy link

When using AWS CLIv2 and configuring sso (MacOS), the default browser is opened and the verification code is used. my browser is signed to the IdP with another user, and the process fails because my user is not assigned to the AWS SSO application.
I want an option to override opening the default browser, and either specify a browser application or suppress automatically opening the browser altogether.

@kyleknap
Copy link
Contributor

kyleknap commented Dec 3, 2019

At the very least, a configuration option to opt-out of auto-opening the browser make sense to me. Marking as a feature request.

@kyleknap kyleknap added v2 feature-request A feature should be added or improved. labels Dec 3, 2019
@allenatdecisiv
Copy link

allenatdecisiv commented Mar 27, 2020

I also would be interested in something similar or even a wait for 5/10 seconds or hit any key to continue type of thing. Or an option/knob to let me handle the loading of the browser and keying in the code.

Right now, my CLI web browser launches (lynx) but I don't get to see the code. I have to exit to return back to AWSCLI:
aws-v2-cli-text-browser

The Python webbrowser is finding lynx because of env TERM being set:
https://github.com/python/cpython/blob/master/Lib/webbrowser.py#L545

There's a env BROWSER knob to control the behaviour:
https://github.com/python/cpython/blob/master/Lib/webbrowser.py#L561

Setting BROWSER did stop lynx from firing up:
$ env BROWSER=/bin/true aws sso login --profile example-sso

$ uname -a
CYGWIN_NT-10.0 FOUREYES 3.1.4(0.340/5/3) 2020-02-19 08:49 x86_64 Cygwin
$ aws --version
aws-cli/2.0.5 Python/3.7.4 CYGWIN_NT-10.0-18363/3.1.4-340.x86_64 botocore/2.0.0dev9
$ pip -V
pip 20.0.2 from /cygdrive/c/Workspace/aws-cli/venv/lib/python3.7/site-packages/pip (python 3.7)
$ python -V
Python 3.7.4

I was able to get it to fire up the browser I wanted and it worked as expected:

$ env BROWSER="$(cygpath --absolute "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")" aws sso login --profile example-sso

@sourcedelica
Copy link

For WSL you can use BROWSER=wslview aws sso login

@eyadmba
Copy link

eyadmba commented Oct 30, 2022

To save someone some time, here's what I did.
In WSL I have this script (aws-login.sh) in the PATH

BROWSER='/mnt/c/Program Files/Google/Chrome/Application/chrome.exe' aws sso login --profile my-profile

and in Windows I have another Powershell script (aws-login.ps1) in the PATH

$Env:BROWSER="C:/Program Files/Google/Chrome/Application/chrome.exe"
aws sso login --profile my-profile

@tim-finnigan tim-finnigan added the p2 This is a standard priority issue label Nov 14, 2022
@microbioticajon
Copy link

I believe aws sso login now has the --no-browser option which covers this:

aws sso login --profile my-profile --no-browser

@deejvince
Copy link
Author

Thank you, with --no-browser this is now solved.
There are now some nice solutions to complete the process, e.g. here https://mziyabo.co/2022/aws-sso-headless-login/

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

@oviliz
Copy link

oviliz commented Sep 28, 2023

Any idea how we do it in MacOS @eyadmba ?

Tried BROWSER='/Applications/Firefox.app' aws sso login --profile my-profile but it keeps opening in the default browser.

@deejvince
Copy link
Author

Check the previous response

@sfragata
Copy link

Your BROWSER path must be completed (until exec file)

I've created an alias for google chrome
alias aws='env BROWSER="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" aws'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p2 This is a standard priority issue sso v2
Projects
None yet
Development

No branches or pull requests

10 participants