Skip to content

Commit f9827dd

Browse files
committed
cleaning up
1 parent bf718b1 commit f9827dd

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

msal/oauth2cli/authcode.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ def obtain_auth_code(listen_port, auth_uri=None, text=None, request_state=None):
3838
"""
3939
if text:
4040
exit_hint = "Visit http://localhost:{p}?auth_code=exit to abort".format(p=listen_port)
41-
browse("http://localhost:{p}?{q}".format(
41+
logger.warning(exit_hint)
42+
page = "http://localhost:{p}?{q}".format(
4243
p=listen_port, q=urlencode({
4344
"text": text,
4445
"link": auth_uri,
4546
"exit_hint": exit_hint,
46-
})))
47-
logger.warning(exit_hint)
47+
}))
48+
browse(page)
4849
else:
4950
browse(auth_uri)
5051
server = AuthcodeRedirectServer(int(listen_port), request_state)

tests/test_e2e.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
logger = logging.getLogger(__name__)
1313
logging.basicConfig(level=logging.INFO)
1414

15-
try: # Python 3
16-
from urllib.parse import urlparse, parse_qs, urlencode
17-
except ImportError: # Fall back to Python 2
18-
from urllib import urlencode
19-
20-
2115

2216
def _get_app_and_auth_code(
2317
client_id,
@@ -30,11 +24,9 @@ def _get_app_and_auth_code(
3024
app = msal.ClientApplication(
3125
client_id, client_secret, authority=authority, http_client=MinimalHttpClient())
3226
redirect_uri = "http://localhost:%d" % port
33-
exit_hint = "Visit http://localhost:{p}?code=exit to abort".format(p=port)
3427
ac = obtain_auth_code(port, auth_uri=app.get_authorization_request_url(
35-
scopes, redirect_uri=redirect_uri),
36-
text="Open this link to sign in. You may use incognito window", **kwargs)
37-
logger.warning(exit_hint)
28+
scopes, redirect_uri=redirect_uri, **kwargs),
29+
text="Open this link to sign in. You may use incognito window")
3830
assert ac is not None
3931
return (app, ac, redirect_uri)
4032

0 commit comments

Comments
 (0)