@@ -1234,16 +1234,17 @@ def _acquire_token_silent_from_cache_and_possibly_refresh_it(
1234
1234
claims = _merge_claims_challenge_and_capabilities (
1235
1235
self ._client_capabilities , claims_challenge ),
1236
1236
)
1237
- if "error" not in response :
1238
- self .token_cache .add (dict (
1239
- client_id = self .client_id ,
1240
- scope = response ["scope" ].split () if "scope" in response else scopes ,
1241
- token_endpoint = self .authority .token_endpoint ,
1242
- response = response .copy (),
1243
- data = kwargs .get ("data" , {}),
1244
- _account_id = response ["_account_id" ],
1245
- ))
1246
- return _clean_up (response )
1237
+ if response : # It means broker was able to provide a decisive outcome
1238
+ if "error" not in response :
1239
+ self .token_cache .add (dict (
1240
+ client_id = self .client_id ,
1241
+ scope = response ["scope" ].split () if "scope" in response else scopes ,
1242
+ token_endpoint = self .authority .token_endpoint ,
1243
+ response = response .copy (),
1244
+ data = kwargs .get ("data" , {}),
1245
+ _account_id = response ["_account_id" ],
1246
+ ))
1247
+ return _clean_up (response ) # Then we use the broker's result
1247
1248
except ImportError :
1248
1249
logger .warning ("PyMsalRuntime is not available" )
1249
1250
result = _clean_up (self ._acquire_token_silent_by_finding_rt_belongs_to_me_or_my_family (
0 commit comments