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
4 changes: 3 additions & 1 deletion msal/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,7 @@ def _acquire_token_interactive_via_broker(
auth_scheme=auth_scheme,
**data)

def initiate_device_flow(self, scopes=None, **kwargs):
def initiate_device_flow(self, scopes=None, claims_challenge=None, **kwargs):
"""Initiate a Device Flow instance,
which will be used in :func:`~acquire_token_by_device_flow`.

Expand All @@ -2341,6 +2341,8 @@ def initiate_device_flow(self, scopes=None, **kwargs):
flow = self.client.initiate_device_flow(
scope=self._decorate_scope(scopes or []),
headers={msal.telemetry.CLIENT_REQUEST_ID: correlation_id},
claims_challenge=_merge_claims_challenge_and_capabilities(
self._client_capabilities, claims_challenge),
**kwargs)
flow[self.DEVICE_FLOW_CORRELATION_ID] = correlation_id
return flow
Expand Down
7 changes: 5 additions & 2 deletions msal/oauth2cli/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class Client(BaseClient): # We choose to implement all 4 grants in 1 class
grant_assertion_encoders = {GRANT_TYPE_SAML2: BaseClient.encode_saml_assertion}


def initiate_device_flow(self, scope=None, **kwargs):
def initiate_device_flow(self, scope=None, claims_challenge=None, **kwargs):
# type: (list, **dict) -> dict
# The naming of this method is following the wording of this specs
# https://tools.ietf.org/html/draft-ietf-oauth-device-flow-12#section-3.1
Expand All @@ -323,8 +323,11 @@ def initiate_device_flow(self, scope=None, **kwargs):
DAE = "device_authorization_endpoint"
if not self.configuration.get(DAE):
raise ValueError("You need to provide device authorization endpoint")
data = {"client_id": self.client_id, "scope": self._stringify(scope or [])}
if claims_challenge:
data["claims"] = claims_challenge
resp = self._http_client.post(self.configuration[DAE],
data={"client_id": self.client_id, "scope": self._stringify(scope or [])},
data=data,
headers=dict(self.default_headers, **kwargs.pop("headers", {})),
**kwargs)
flow = json.loads(resp.text)
Expand Down
Loading