Skip to content

Commit c380781

Browse files
committed
adjust check order
1 parent 6578ca2 commit c380781

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

msal/application.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,12 +1552,8 @@ def _acquire_token_silent_from_cache_and_possibly_refresh_it(
15521552
correlation_id=correlation_id,
15531553
auth_scheme=auth_scheme,
15541554
**data)
1555-
if response: # Broker provides a decisive outcome
1556-
account_was_established_by_broker = account.get(
1557-
"account_source") == _GRANT_TYPE_BROKER
1558-
broker_attempt_succeeded_just_now = "error" not in response
1559-
1560-
if (response.get("access_token") and force_refresh):
1555+
1556+
if (force_refresh and response.get("access_token")):
15611557
at_to_renew = response.get("access_token")
15621558
response = _acquire_token_silently(
15631559
"https://{}/{}".format(self.authority.instance, self.authority.tenant),
@@ -1570,6 +1566,11 @@ def _acquire_token_silent_from_cache_and_possibly_refresh_it(
15701566
auth_scheme=auth_scheme,
15711567
at_to_renew= at_to_renew,
15721568
**data)
1569+
1570+
if response: # Broker provides a decisive outcome
1571+
account_was_established_by_broker = account.get(
1572+
"account_source") == _GRANT_TYPE_BROKER
1573+
broker_attempt_succeeded_just_now = "error" not in response
15731574

15741575
if account_was_established_by_broker or broker_attempt_succeeded_just_now:
15751576
return self._process_broker_response(response, scopes, data)

0 commit comments

Comments
 (0)