Skip to content

Commit ed4c796

Browse files
committed
Merge branch 'customizable-browser' into dev
2 parents bbb9af5 + bce6cc0 commit ed4c796

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

oauth2cli/authcode.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ def is_wsl():
4848
def _browse(auth_uri, browser_name=None): # throws ImportError, webbrowser.Error
4949
"""Browse uri with named browser. Default browser is customizable by $BROWSER"""
5050
import webbrowser # Lazy import. Some distro may not have this.
51-
browser_opened = webbrowser.get(browser_name).open(auth_uri)
51+
if browser_name:
52+
browser_opened = webbrowser.get(browser_name).open(auth_uri)
53+
else:
54+
# This one can survive BROWSER=nonexist, while get(None).open(...) can not
55+
browser_opened = webbrowser.open(auth_uri)
5256

5357
# In WSL which doesn't have www-browser, try launching browser with PowerShell
5458
if not browser_opened and is_wsl():

0 commit comments

Comments
 (0)