@@ -107,6 +107,7 @@ class ClientApplication(object):
107107 ACQUIRE_TOKEN_BY_DEVICE_FLOW_ID = "622"
108108 ACQUIRE_TOKEN_FOR_CLIENT_ID = "730"
109109 ACQUIRE_TOKEN_BY_AUTHORIZATION_CODE_ID = "832"
110+ ACQUIRE_TOKEN_INTERACTIVE = "169"
110111 GET_ACCOUNTS_ID = "902"
111112 REMOVE_ACCOUNT_ID = "903"
112113
@@ -318,7 +319,6 @@ def initiate_auth_code_flow(
318319
319320 :param list scope:
320321 It is a list of case-sensitive strings.
321- Some ID provider can accept empty string to represent default scope.
322322 :param str redirect_uri:
323323 Optional. If not specified, server will use the pre-registered one.
324324 :param str state:
@@ -998,6 +998,78 @@ def __init__(self, client_id, client_credential=None, **kwargs):
998998 super (PublicClientApplication , self ).__init__ (
999999 client_id , client_credential = None , ** kwargs )
10001000
1001+ def acquire_token_interactive (
1002+ self ,
1003+ scopes , # type: list[str]
1004+ prompt = None ,
1005+ login_hint = None , # type: Optional[str]
1006+ domain_hint = None , # type: Optional[str]
1007+ claims_challenge = None ,
1008+ timeout = None ,
1009+ port = None ,
1010+ ** kwargs ):
1011+ """Acquire token interactively i.e. via a local browser.
1012+
1013+ :param list scope:
1014+ It is a list of case-sensitive strings.
1015+ :param str prompt:
1016+ By default, no prompt value will be sent, not even "none".
1017+ You will have to specify a value explicitly.
1018+ Its valid values are defined in Open ID Connect specs
1019+ https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
1020+ :param str login_hint:
1021+ Optional. Identifier of the user. Generally a User Principal Name (UPN).
1022+ :param domain_hint:
1023+ Can be one of "consumers" or "organizations" or your tenant domain "contoso.com".
1024+ If included, it will skip the email-based discovery process that user goes
1025+ through on the sign-in page, leading to a slightly more streamlined user experience.
1026+ More information on possible values
1027+ `here <https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code>`_ and
1028+ `here <https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oapx/86fb452d-e34a-494e-ac61-e526e263b6d8>`_.
1029+
1030+ :param claims_challenge:
1031+ The claims_challenge parameter requests specific claims requested by the resource provider
1032+ in the form of a claims_challenge directive in the www-authenticate header to be
1033+ returned from the UserInfo Endpoint and/or in the ID Token and/or Access Token.
1034+ It is a string of a JSON object which contains lists of claims being requested from these locations.
1035+
1036+ :param int timeout:
1037+ This method will block the current thread.
1038+ This parameter specifies the timeout value in seconds.
1039+ Default value ``None`` means wait indefinitely.
1040+
1041+ :param int port:
1042+ The port to be used to listen to an incoming auth response.
1043+ By default we will use a system-allocated port.
1044+ (The rest of the redirect_uri is hard coded as ``http://localhost``.)
1045+
1046+ :return:
1047+ - A dict containing no "error" key,
1048+ and typically contains an "access_token" key,
1049+ if cache lookup succeeded.
1050+ - A dict containing an "error" key, when token refresh failed.
1051+ """
1052+ self ._validate_ssh_cert_input_data (kwargs .get ("data" , {}))
1053+ claims = _merge_claims_challenge_and_capabilities (
1054+ self ._client_capabilities , claims_challenge )
1055+ return self .client .obtain_token_by_browser (
1056+ scope = decorate_scope (scopes , self .client_id ) if scopes else None ,
1057+ redirect_uri = "http://localhost:{port}" .format (
1058+ # Hardcode the host, for now. AAD portal rejects 127.0.0.1 anyway
1059+ port = port or 0 ),
1060+ prompt = prompt ,
1061+ login_hint = login_hint ,
1062+ domain_hint = domain_hint ,
1063+ timeout = timeout ,
1064+ auth_params = {"claims" : claims },
1065+ data = dict (kwargs .pop ("data" , {}), claims = claims ),
1066+ headers = {
1067+ CLIENT_REQUEST_ID : _get_new_correlation_id (),
1068+ CLIENT_CURRENT_TELEMETRY : _build_current_telemetry_request_header (
1069+ self .ACQUIRE_TOKEN_INTERACTIVE ),
1070+ },
1071+ ** kwargs )
1072+
10011073 def initiate_device_flow (self , scopes = None , ** kwargs ):
10021074 """Initiate a Device Flow instance,
10031075 which will be used in :func:`~acquire_token_by_device_flow`.
0 commit comments