@@ -487,15 +487,16 @@ def set_proxy(self, proxy_server, proxy_port, proxy_username,
487487 @property
488488 def msal_client (self ):
489489 """ Returns the msal client or creates it if it's not already done """
490- if self .auth_flow_type == 'public' :
491- client = PublicClientApplication (client_id = self .auth [0 ], authority = self ._msal_authority )
492- elif self .auth_flow_type in ('authorization' , 'credentials' ):
493- client = ConfidentialClientApplication (client_id = self .auth [0 ], client_credential = self .auth [1 ],
494- authority = self ._msal_authority )
495- else :
496- raise ValueError ('"auth_flow_type" must be "authorization", "public" or "credentials"' )
497- self ._msal_client = client
498- return client
490+ if self ._msal_client is None :
491+ if self .auth_flow_type == 'public' :
492+ client = PublicClientApplication (client_id = self .auth [0 ], authority = self ._msal_authority )
493+ elif self .auth_flow_type in ('authorization' , 'credentials' ):
494+ client = ConfidentialClientApplication (client_id = self .auth [0 ], client_credential = self .auth [1 ],
495+ authority = self ._msal_authority )
496+ else :
497+ raise ValueError ('"auth_flow_type" must be "authorization", "public" or "credentials"' )
498+ self ._msal_client = client
499+ return self ._msal_client
499500
500501 def get_token_with_msal_simple (self , requested_scopes = None ):
501502 """ Gets the token using"""
@@ -544,7 +545,7 @@ def get_authorization_url(self, requested_scopes=None,
544545 if not scopes :
545546 raise ValueError ('Must provide at least one scope' )
546547
547- flow = self ._msal_client .initiate_auth_code_flow (scopes = scopes , redirect_uri = redirect_uri )
548+ flow = self .msal_client .initiate_auth_code_flow (scopes = scopes , redirect_uri = redirect_uri )
548549
549550 return flow .get ('auth_uri' ), flow
550551
@@ -569,17 +570,17 @@ def request_token(self, authorization_url, *,
569570 parsed = urlparse (authorization_url )
570571 query_params_dict = {k : v [0 ] for k , v in parse_qs (parsed .query ).items ()}
571572
572- result = self ._msal_client .acquire_token_by_auth_code_flow (flow , auth_response = query_params_dict )
573-
573+ result = self .msal_client .acquire_token_by_auth_code_flow (flow , auth_response = query_params_dict )
574+ print ( result )
574575 if "access_token" not in result :
575576 log .error ('Unable to fetch auth token. Error: {}' .format (result .get ("error" )))
576577 return False
577578 else :
578579 access_token = result ["access_token" ]
579580 # TODO: retrieve token data from results and create a Token object with it
580581 # How to pass this Token object into msal again?
581- if store_token :
582- self .token_backend .save_token ()
582+ # if store_token:
583+ # self.token_backend.save_token()
583584
584585 return True
585586
0 commit comments