Skip to content

Commit 05d19b3

Browse files
committed
Change acquire_token_with_username_password(..., scope, ...) to ...by...(..., scopes, ...)
1 parent 3f380c5 commit 05d19b3

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

msal/application.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,20 +279,20 @@ class PublicClientApplication(ClientApplication): # browser app or mobile app
279279
# super(PublicClientApplication, self).__init__(client_id, **kwargs)
280280
# self.redirect_uri = redirect_uri or self.OUT_OF_BAND
281281

282-
def acquire_token_with_username_password(
283-
self, username, password, scope=None, **kwargs):
282+
def acquire_token_by_username_password(
283+
self, username, password, scopes=None, **kwargs):
284284
"""Gets a token for a given resource via user credentails."""
285-
scope = decorate_scope(scope, self.client_id)
285+
scopes = decorate_scope(scopes, self.client_id)
286286
if not self.authority.is_adfs:
287287
user_realm_result = self.authority.user_realm_discovery(username)
288288
if user_realm_result.get("account_type") == "Federated":
289-
return self._acquire_token_with_username_password_federated(
290-
user_realm_result, username, password, scope=scope, **kwargs)
291-
return self.client.obtain_token_with_username_password(
292-
username, password, scope=scope, **kwargs)
289+
return self._acquire_token_by_username_password_federated(
290+
user_realm_result, username, password, scopes=scopes, **kwargs)
291+
return self.client.obtain_token_by_username_password(
292+
username, password, scope=scopes, **kwargs)
293293

294-
def _acquire_token_with_username_password_federated(
295-
self, user_realm_result, username, password, scope=None, **kwargs):
294+
def _acquire_token_by_username_password_federated(
295+
self, user_realm_result, username, password, scopes=None, **kwargs):
296296
wstrust_endpoint = {}
297297
if user_realm_result.get("federation_metadata_url"):
298298
wstrust_endpoint = mex.send_request(
@@ -313,9 +313,9 @@ def _acquire_token_with_username_password_federated(
313313
if not grant_type:
314314
raise RuntimeError(
315315
"RSTR returned unknown token type: %s", wstrust_result.get("type"))
316-
return self.client.obtain_token_with_assertion(
316+
return self.client.obtain_token_by_assertion(
317317
b64encode(wstrust_result["token"]),
318-
grant_type=grant_type, scope=scope, **kwargs)
318+
grant_type=grant_type, scope=scopes, **kwargs)
319319

320320
def acquire_token(
321321
self,

tests/test_application.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class TestPublicClientApplication(Oauth2TestCase):
9999
def test_username_password(self):
100100
self.app = PublicClientApplication(
101101
CONFIG["client_id"], authority=CONFIG["authority"])
102-
result = self.app.acquire_token_with_username_password(
103-
CONFIG["username"], CONFIG["password"], scope=CONFIG.get("scope"))
102+
result = self.app.acquire_token_by_username_password(
103+
CONFIG["username"], CONFIG["password"], scopes=CONFIG.get("scope"))
104104
self.assertLoosely(result)
105105
self.assertCacheWorks(result)
106106

0 commit comments

Comments
 (0)