Skip to content

Commit 27b5054

Browse files
committed
UX improvement based on recent Device Flow tests
1 parent f4a0ba0 commit 27b5054

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sample/device_flow_sample.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,18 @@
5151

5252
if not result:
5353
logging.info("No suitable token exists in cache. Let's get a new one from AAD.")
54+
5455
flow = app.initiate_device_flow(scopes=config["scope"])
56+
if "user_code" not in flow:
57+
raise ValueError(
58+
"Fail to create device flow. Err: %s" % json.dumps(flow, indent=4))
59+
5560
print(flow["message"])
61+
sys.stdout.flush() # Some terminal needs this to ensure the message is shown
62+
5663
# Ideally you should wait here, in order to save some unnecessary polling
57-
# input("Press Enter after you successfully login from another device...")
64+
# input("Press Enter after signing in from another device to proceed, CTRL+C to abort.")
65+
5866
result = app.acquire_token_by_device_flow(flow) # By default it will block
5967
# You can follow this instruction to shorten the block time
6068
# https://msal-python.readthedocs.io/en/latest/#msal.PublicClientApplication.acquire_token_by_device_flow

0 commit comments

Comments
 (0)