Skip to content

Commit 16278c8

Browse files
committed
Make acquire_token_silent(..., account, ...) a required parameter
1 parent b547c99 commit 16278c8

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

msal/application.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,32 @@ def get_accounts(self, username=None):
212212
return accounts
213213

214214
def acquire_token_silent(
215-
self, scopes,
216-
account=None, # one of the account object returned by get_accounts()
215+
self,
216+
scopes, # type: List[str]
217+
account, # type: Optional[Account]
217218
authority=None, # See get_authorization_request_url()
218-
force_refresh=False, # To force refresh an Access Token (not a RT)
219+
force_refresh=False, # type: Optional[boolean]
219220
**kwargs):
221+
"""Acquire an access token for given account, without user interaction.
222+
223+
It is done either by finding a valid access token from cache,
224+
or by finding a valid refresh token from cache and then automatically
225+
use it to redeem a new access token.
226+
227+
The return value will be an new or cached access token, or None.
228+
229+
:param scopes: Scopes, represented as a list of strings
230+
:param account:
231+
one of the account object returned by get_accounts(),
232+
or use None when you want to find an access token for this client.
233+
:param force_refresh:
234+
If True, it will skip Access Token look-up,
235+
and try to find a Refresh Token to obtain a new Access Token.
236+
"""
220237
assert isinstance(scopes, list), "Invalid parameter type"
221238
the_authority = Authority(authority) if authority else self.authority
222239

223-
if force_refresh == False:
240+
if not force_refresh:
224241
matches = self.token_cache.find(
225242
self.token_cache.CredentialType.ACCESS_TOKEN,
226243
target=scopes,

0 commit comments

Comments
 (0)