Skip to content

Commit a27e128

Browse files
committed
Robust way to detect public client
1 parent 16913a0 commit a27e128

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

msal/application.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,9 @@ def __init__(
470470
self.http_client, validate_authority=False)
471471
else:
472472
raise
473-
is_public_app = (isinstance(self, PublicClientApplication) or
474-
(isinstance(self, ClientApplication) and not self.client_credential))
475-
self._enable_broker = (is_public_app
473+
is_confidential_app = bool(
474+
isinstance(self, ConfidentialClientApplication) or self.client_credential)
475+
self._enable_broker = (not is_confidential_app
476476
and sys.platform == "win32"
477477
and not self.authority.is_adfs and not self.authority._is_b2c)
478478

@@ -1226,8 +1226,12 @@ def _acquire_token_silent_from_cache_and_possibly_refresh_it(
12261226
refresh_reason = msal.telemetry.FORCE_REFRESH # TODO: It could also mean claims_challenge
12271227
assert refresh_reason, "It should have been established at this point"
12281228
try:
1229-
if self._enable_broker: # If interactive flow or ROPC were not through broker,
1230-
# the _acquire_token_silently() is unlikely to locate the account.
1229+
if (
1230+
self._enable_broker
1231+
# If interactive flow or ROPC were not through broker,
1232+
# the _acquire_token_silently() is unlikely to locate the account.
1233+
and account is not None # MSAL Python requires this
1234+
):
12311235
try:
12321236
from .wam import _acquire_token_silently
12331237
response = _acquire_token_silently(

0 commit comments

Comments
 (0)