@@ -34,14 +34,17 @@ def acquire_token_silent(
3434 policy = '' ,
3535 force_refresh = False , # To force refresh an Access Token (not a RT)
3636 ** kwargs ):
37- a = Authority (authority ) if authority else self .authority
38- client = oauth2 .Client (self .client_id , token_endpoint = a .token_endpoint )
37+ the_authority = Authority (authority ) if authority else self .authority
3938 refresh_token = kwargs .get ('refresh_token' ) # For testing purpose
40- response = client .get_token_by_refresh_token (
41- refresh_token ,
42- scope = decorate_scope (scope , self .client_id , policy ),
43- client_secret = getattr (self , 'client_credential' ), # TODO: JWT too
44- query = {'policy' : policy } if policy else None )
39+ response = oauth2 .Client (
40+ self .client_id , token_endpoint = the_authority .token_endpoint ,
41+ default_body = self ._build_auth_parameters (
42+ self .client_credential ,
43+ the_authority .token_endpoint , self .client_id )
44+ ).get_token_by_refresh_token (
45+ refresh_token ,
46+ scope = decorate_scope (scope , self .client_id , policy ),
47+ query = {'p' : policy } if policy else None )
4548 # TODO: refresh the refresh_token
4649 return response
4750
@@ -127,9 +130,10 @@ def get_authorization_request_url(
127130 sending them on the wire.)
128131 :param str state: Recommended by OAuth2 for CSRF protection.
129132 """
130- a = Authority (authority ) if authority else self .authority
133+ the_authority = Authority (authority ) if authority else self .authority
131134 grant = oauth2 .AuthorizationCodeGrant (
132- self .client_id , authorization_endpoint = a .authorization_endpoint )
135+ self .client_id ,
136+ authorization_endpoint = the_authority .authorization_endpoint )
133137 return grant .authorization_url (
134138 redirect_uri = redirect_uri , state = state , login_hint = login_hint ,
135139 scope = decorate_scope (scope , self .client_id , policy ),
@@ -169,13 +173,15 @@ def acquire_token_by_authorization_code(
169173 # So in theory, you can omit scope here when you were working with only
170174 # one scope. But, MSAL decorates your scope anyway, so they are never
171175 # really empty.
172- grant = oauth2 .AuthorizationCodeGrant (
173- self .client_id , token_endpoint = self .authority .token_endpoint )
174- return grant .get_token (
175- code , redirect_uri = redirect_uri ,
176- scope = decorate_scope (scope , self .client_id , policy ),
177- client_secret = self .client_credential , # TODO: Support certificate
178- query = {'policy' : policy } if policy else None )
176+ return oauth2 .AuthorizationCodeGrant (
177+ self .client_id , token_endpoint = self .authority .token_endpoint ,
178+ default_body = self ._build_auth_parameters (
179+ self .client_credential ,
180+ self .authority .token_endpoint , self .client_id )
181+ ).get_token (
182+ code , redirect_uri = redirect_uri ,
183+ scope = decorate_scope (scope , self .client_id , policy ),
184+ query = {'p' : policy } if policy else None )
179185
180186 def acquire_token_on_behalf_of (
181187 self , user_assertion , scope , authority = None , policy = '' ):
0 commit comments