@@ -1046,6 +1046,15 @@ def _get_authority_aliases(self, instance):
1046
1046
def remove_account (self , account ):
1047
1047
"""Sign me out and forget me from token cache"""
1048
1048
self ._forget_me (account )
1049
+ if self ._enable_broker :
1050
+ try :
1051
+ from .broker import _signout_silently
1052
+ except RuntimeError : # TODO: TBD
1053
+ logger .debug ("Broker is unavailable on this platform. Fallback to non-broker." )
1054
+ else :
1055
+ error = _signout_silently (self .client_id , account ["local_account_id" ])
1056
+ if error :
1057
+ logger .debug ("_signout_silently() returns error: %s" , error )
1049
1058
1050
1059
def _sign_out (self , home_account ):
1051
1060
# Remove all relevant RTs and ATs from token cache
@@ -1656,6 +1665,7 @@ def acquire_token_interactive(
1656
1665
and typically contains an "access_token" key.
1657
1666
- A dict containing an "error" key, when token refresh failed.
1658
1667
"""
1668
+ self ._validate_ssh_cert_input_data (kwargs .get ("data" , {}))
1659
1669
claims = _merge_claims_challenge_and_capabilities (
1660
1670
self ._client_capabilities , claims_challenge )
1661
1671
if self ._enable_broker :
@@ -1672,30 +1682,37 @@ def acquire_token_interactive(
1672
1682
logger .debug (kwargs ["welcome_template" ]) # Experimental
1673
1683
authority = "https://{}/{}" .format (
1674
1684
self .authority .instance , self .authority .tenant )
1675
- validate_authority = ("no"
1676
- if self .authority ._validate_authority is False
1677
- or self .authority .is_adfs or self .authority ._is_b2c
1685
+ validate_authority = (
1686
+ "no" if self .authority ._validate_authority is False
1687
+ or self .authority .is_adfs or self .authority ._is_b2c
1678
1688
else None )
1679
- if (prompt and prompt != "none" ) or login_hint :
1680
- response = _signin_interactively (
1681
- authority , self .client_id , scopes ,
1682
- validateAuthority = validate_authority ,
1683
- login_hint = login_hint ,
1684
- prompt = prompt ,
1685
- claims = claims ,
1686
- max_age = max_age , # Broker may choose to trust the auth_time returned by AAD
1687
- window = window ,
1688
- )
1689
- else :
1689
+
1690
+ # Call _signin_silently() and/or _signin_interactively()
1691
+ if prompt == "none" or (not prompt and not login_hint ):
1690
1692
response = _signin_silently (
1691
1693
authority , self .client_id , scopes ,
1692
1694
validateAuthority = validate_authority ,
1693
1695
claims = claims ,
1694
- max_age = max_age , # Broker may choose to trust the auth_time returned by AAD
1695
- )
1696
+ max_age = max_age ,
1697
+ ** kwargs .get ("data" , {}))
1698
+ import pymsalruntime
1699
+ if prompt == "none" or response .get ("_broker_status" ) not in (
1700
+ pymsalruntime .Response_Status .Status_AccountUnusable ,
1701
+ pymsalruntime .Response_Status .Status_InteractionRequired ,
1702
+ ):
1703
+ return self ._process_broker_response (
1704
+ response , scopes , kwargs .get ("data" , {}))
1705
+ response = _signin_interactively (
1706
+ authority , self .client_id , scopes ,
1707
+ validateAuthority = validate_authority ,
1708
+ login_hint = login_hint ,
1709
+ prompt = prompt ,
1710
+ claims = claims ,
1711
+ max_age = max_age ,
1712
+ window = window ,
1713
+ ** kwargs .get ("data" , {}))
1696
1714
return self ._process_broker_response (response , scopes , kwargs .get ("data" , {}))
1697
1715
1698
- self ._validate_ssh_cert_input_data (kwargs .get ("data" , {}))
1699
1716
telemetry_context = self ._build_telemetry_context (
1700
1717
self .ACQUIRE_TOKEN_INTERACTIVE )
1701
1718
response = _clean_up (self .client .obtain_token_by_browser (
0 commit comments