Skip to content

Commit 003a755

Browse files
committed
Robust way to detect public client
1 parent 0ecc477 commit 003a755

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
@@ -466,9 +466,9 @@ def __init__(
466466
self.http_client, validate_authority=False)
467467
else:
468468
raise
469-
is_public_app = (isinstance(self, PublicClientApplication) or
470-
(isinstance(self, ClientApplication) and not self.client_credential))
471-
self._enable_broker = (is_public_app
469+
is_confidential_app = bool(
470+
isinstance(self, ConfidentialClientApplication) or self.client_credential)
471+
self._enable_broker = (not is_confidential_app
472472
and sys.platform == "win32"
473473
and not self.authority.is_adfs and not self.authority._is_b2c)
474474

@@ -1222,8 +1222,12 @@ def _acquire_token_silent_from_cache_and_possibly_refresh_it(
12221222
refresh_reason = msal.telemetry.FORCE_REFRESH # TODO: It could also mean claims_challenge
12231223
assert refresh_reason, "It should have been established at this point"
12241224
try:
1225-
if self._enable_broker: # If interactive flow or ROPC were not through broker,
1226-
# the _acquire_token_silently() is unlikely to locate the account.
1225+
if (
1226+
self._enable_broker
1227+
# If interactive flow or ROPC were not through broker,
1228+
# the _acquire_token_silently() is unlikely to locate the account.
1229+
and account is not None # MSAL Python requires this
1230+
):
12271231
try:
12281232
from .wam import _acquire_token_silently
12291233
response = _acquire_token_silently(

0 commit comments

Comments
 (0)