@@ -190,9 +190,9 @@ def _perform_wstrust_assertion_oauth_exchange(self, wstrust_response):
190190
191191 return self ._oauth_get_token (oauth_parameters )
192192
193- def _perform_wstrust_exchange (self , wstrust_endpoint , wstrust_endpoint_version , username , password ):
193+ def _perform_wstrust_exchange (self , wstrust_endpoint , wstrust_endpoint_version , cloud_audience_urn , username , password ):
194194
195- wstrust = self ._create_wstrust_request (wstrust_endpoint , "urn:federation:MicrosoftOnline" ,
195+ wstrust = self ._create_wstrust_request (wstrust_endpoint , cloud_audience_urn ,
196196 wstrust_endpoint_version )
197197 result = wstrust .acquire_token (username , password )
198198
@@ -204,15 +204,16 @@ def _perform_wstrust_exchange(self, wstrust_endpoint, wstrust_endpoint_version,
204204
205205 return result
206206
207- def _perform_username_password_for_access_token_exchange (self , wstrust_endpoint , wstrust_endpoint_version ,
207+ def _perform_username_password_for_access_token_exchange (self , wstrust_endpoint , wstrust_endpoint_version , cloud_audience_urn ,
208208 username , password ):
209- wstrust_response = self ._perform_wstrust_exchange (wstrust_endpoint , wstrust_endpoint_version ,
209+ wstrust_response = self ._perform_wstrust_exchange (wstrust_endpoint , wstrust_endpoint_version , cloud_audience_urn ,
210210 username , password )
211211 return self ._perform_wstrust_assertion_oauth_exchange (wstrust_response )
212212
213213 def _get_token_username_password_federated (self , username , password ):
214214 self ._log .debug ("Acquiring token with username password for federated user" )
215215
216+ cloud_audience_urn = self ._user_realm .cloud_audience_urn
216217 if not self ._user_realm .federation_metadata_url :
217218 self ._log .warn ("Unable to retrieve federationMetadataUrl from AAD. "
218219 "Attempting fallback to AAD supplied endpoint." )
@@ -228,7 +229,7 @@ def _get_token_username_password_federated(self, username, password):
228229
229230 return self ._perform_username_password_for_access_token_exchange (
230231 self ._user_realm .federation_active_auth_url ,
231- wstrust_version , username , password )
232+ wstrust_version , cloud_audience_urn , username , password )
232233 else :
233234 mex_endpoint = self ._user_realm .federation_metadata_url
234235 self ._log .debug (
@@ -253,6 +254,7 @@ def _get_token_username_password_federated(self, username, password):
253254 raise AdalError ('AAD did not return a WSTrust endpoint. Unable to proceed.' )
254255
255256 return self ._perform_username_password_for_access_token_exchange (wstrust_endpoint , wstrust_version ,
257+ cloud_audience_urn ,
256258 username , password )
257259 @staticmethod
258260 def _parse_wstrust_version_from_federation_active_authurl (federation_active_authurl ):
0 commit comments