Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor and fix a bug in the initiate_device_flow()
  • Loading branch information
rayluo committed Dec 17, 2019
commit 444800349efb5c3ab659d5549d05d50de60ca9e6
11 changes: 8 additions & 3 deletions msal/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,16 @@ def initiate_device_flow(self, scopes=None, **kwargs):
- A successful response would contain "user_code" key, among others
- an error response would contain some other readable key/value pairs.
"""
return self.client.initiate_device_flow(
# x-client-current-telemetry is not currently required by our telemetry
headers={'client-request-id': _get_new_correlation_id()},
correlation_id = _get_new_correlation_id()
flow = self.client.initiate_device_flow(
scope=decorate_scope(scopes or [], self.client_id),
headers={
'client-request-id': correlation_id,
# 'x-client-current-telemetry' is not currently required
},
**kwargs)
flow["_client_request_id"] = correlation_id
return flow

def acquire_token_by_device_flow(self, flow, **kwargs):
"""Obtain token by a device flow object, with customizable polling effect.
Expand Down
1 change: 0 additions & 1 deletion msal/oauth2cli/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def initiate_device_flow(self, scope=None, timeout=None, **kwargs):
flow["interval"] = int(flow.get("interval", 5)) # Some IdP returns string
flow["expires_in"] = int(flow.get("expires_in", 1800))
flow["expires_at"] = time.time() + flow["expires_in"] # We invent this
flow["_client_request_id"] = kwargs.get('client-request-id') # correlation Id for telemetry
return flow

def _obtain_token_by_device_flow(self, flow, **kwargs):
Expand Down