2121
2222
2323# The __init__.py will import this. Not the other way around.
24- __version__ = "1.8 .0"
24+ __version__ = "1.9 .0"
2525
2626logger = logging .getLogger (__name__ )
2727
@@ -56,7 +56,9 @@ def decorate_scope(
5656CLIENT_CURRENT_TELEMETRY = 'x-client-current-telemetry'
5757
5858def _get_new_correlation_id ():
59- return str (uuid .uuid4 ())
59+ correlation_id = str (uuid .uuid4 ())
60+ logger .debug ("Generates correlation_id: %s" , correlation_id )
61+ return correlation_id
6062
6163
6264def _build_current_telemetry_request_header (public_api_id , force_refresh = False ):
@@ -439,16 +441,20 @@ def get_authorization_request_url(
439441 {"authorization_endpoint" : the_authority .authorization_endpoint },
440442 self .client_id ,
441443 http_client = self .http_client )
442- return client .build_auth_request_uri (
443- response_type = response_type ,
444- redirect_uri = redirect_uri , state = state , login_hint = login_hint ,
445- prompt = prompt ,
446- scope = decorate_scope (scopes , self .client_id ),
447- nonce = nonce ,
448- domain_hint = domain_hint ,
449- claims = _merge_claims_challenge_and_capabilities (
450- self ._client_capabilities , claims_challenge ),
451- )
444+ warnings .warn (
445+ "Change your get_authorization_request_url() "
446+ "to initiate_auth_code_flow()" , DeprecationWarning )
447+ with warnings .catch_warnings (record = True ):
448+ return client .build_auth_request_uri (
449+ response_type = response_type ,
450+ redirect_uri = redirect_uri , state = state , login_hint = login_hint ,
451+ prompt = prompt ,
452+ scope = decorate_scope (scopes , self .client_id ),
453+ nonce = nonce ,
454+ domain_hint = domain_hint ,
455+ claims = _merge_claims_challenge_and_capabilities (
456+ self ._client_capabilities , claims_challenge ),
457+ )
452458
453459 def acquire_token_by_auth_code_flow (
454460 self , auth_code_flow , auth_response , scopes = None , ** kwargs ):
@@ -570,20 +576,24 @@ def acquire_token_by_authorization_code(
570576 # really empty.
571577 assert isinstance (scopes , list ), "Invalid parameter type"
572578 self ._validate_ssh_cert_input_data (kwargs .get ("data" , {}))
573- return self .client .obtain_token_by_authorization_code (
574- code , redirect_uri = redirect_uri ,
575- scope = decorate_scope (scopes , self .client_id ),
576- headers = {
577- CLIENT_REQUEST_ID : _get_new_correlation_id (),
578- CLIENT_CURRENT_TELEMETRY : _build_current_telemetry_request_header (
579- self .ACQUIRE_TOKEN_BY_AUTHORIZATION_CODE_ID ),
580- },
581- data = dict (
582- kwargs .pop ("data" , {}),
583- claims = _merge_claims_challenge_and_capabilities (
584- self ._client_capabilities , claims_challenge )),
585- nonce = nonce ,
586- ** kwargs )
579+ warnings .warn (
580+ "Change your acquire_token_by_authorization_code() "
581+ "to acquire_token_by_auth_code_flow()" , DeprecationWarning )
582+ with warnings .catch_warnings (record = True ):
583+ return self .client .obtain_token_by_authorization_code (
584+ code , redirect_uri = redirect_uri ,
585+ scope = decorate_scope (scopes , self .client_id ),
586+ headers = {
587+ CLIENT_REQUEST_ID : _get_new_correlation_id (),
588+ CLIENT_CURRENT_TELEMETRY : _build_current_telemetry_request_header (
589+ self .ACQUIRE_TOKEN_BY_AUTHORIZATION_CODE_ID ),
590+ },
591+ data = dict (
592+ kwargs .pop ("data" , {}),
593+ claims = _merge_claims_challenge_and_capabilities (
594+ self ._client_capabilities , claims_challenge )),
595+ nonce = nonce ,
596+ ** kwargs )
587597
588598 def get_accounts (self , username = None ):
589599 """Get a list of accounts which previously signed in, i.e. exists in cache.
@@ -942,7 +952,7 @@ def _validate_ssh_cert_input_data(self, data):
942952 "you must include a string parameter named 'key_id' "
943953 "which identifies the key in the 'req_cnf' argument." )
944954
945- def acquire_token_by_refresh_token (self , refresh_token , scopes ):
955+ def acquire_token_by_refresh_token (self , refresh_token , scopes , ** kwargs ):
946956 """Acquire token(s) based on a refresh token (RT) obtained from elsewhere.
947957
948958 You use this method only when you have old RTs from elsewhere,
@@ -965,6 +975,7 @@ def acquire_token_by_refresh_token(self, refresh_token, scopes):
965975 * A dict contains "error" and some other keys, when error happened.
966976 * A dict contains no "error" key means migration was successful.
967977 """
978+ self ._validate_ssh_cert_input_data (kwargs .get ("data" , {}))
968979 return self .client .obtain_token_by_refresh_token (
969980 refresh_token ,
970981 scope = decorate_scope (scopes , self .client_id ),
@@ -976,7 +987,7 @@ def acquire_token_by_refresh_token(self, refresh_token, scopes):
976987 rt_getter = lambda rt : rt ,
977988 on_updating_rt = False ,
978989 on_removing_rt = lambda rt_item : None , # No OP
979- )
990+ ** kwargs )
980991
981992
982993class PublicClientApplication (ClientApplication ): # browser app or mobile app
@@ -1233,6 +1244,7 @@ def acquire_token_for_client(self, scopes, claims_challenge=None, **kwargs):
12331244 - an error response would contain "error" and usually "error_description".
12341245 """
12351246 # TBD: force_refresh behavior
1247+ self ._validate_ssh_cert_input_data (kwargs .get ("data" , {}))
12361248 return self .client .obtain_token_for_client (
12371249 scope = scopes , # This grant flow requires no scope decoration
12381250 headers = {
@@ -1294,4 +1306,3 @@ def acquire_token_on_behalf_of(self, user_assertion, scopes, claims_challenge=No
12941306 self .ACQUIRE_TOKEN_ON_BEHALF_OF_ID ),
12951307 },
12961308 ** kwargs )
1297-
0 commit comments