@@ -221,8 +221,6 @@ class ClientApplication(object):
221221 "You can enable broker by following these instructions. "
222222 "https://msal-python.readthedocs.io/en/latest/#publicclientapplication" )
223223
224- _enable_broker = False
225-
226224 def __init__ (
227225 self , client_id ,
228226 client_credential = None , authority = None , validate_authority = True ,
@@ -651,14 +649,22 @@ def _decide_broker(self, allow_broker, enable_pii_log):
651649 "enable_broker_on_windows=True, "
652650 "enable_broker_on_mac=...)" ,
653651 DeprecationWarning )
654- self ._enable_broker = self ._enable_broker or (
652+ opted_in_for_broker = (
653+ self ._enable_broker # True means Opted-in from PCA
654+ or (
655655 # When we started the broker project on Windows platform,
656656 # the allow_broker was meant to be cross-platform. Now we realize
657657 # that other platforms have different redirect_uri requirements,
658658 # so the old allow_broker is deprecated and will only for Windows.
659659 allow_broker and sys .platform == "win32" )
660- if (self ._enable_broker and not is_confidential_app
661- and not self .authority .is_adfs and not self .authority ._is_b2c ):
660+ )
661+ self ._enable_broker = ( # This same variable will also store the state
662+ opted_in_for_broker
663+ and not is_confidential_app
664+ and not self .authority .is_adfs
665+ and not self .authority ._is_b2c
666+ )
667+ if self ._enable_broker :
662668 try :
663669 _init_broker (enable_pii_log )
664670 except RuntimeError :
0 commit comments