Skip to content

Commit 6490e18

Browse files
committed
Fix regression on credential client grant
1 parent 10f7888 commit 6490e18

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

msal/token_cache.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,16 @@ def add(self, event, now=None):
121121
id_token_claims = (
122122
decode_id_token(id_token, client_id=event["client_id"])
123123
if id_token else {})
124-
client_info = (
125-
json.loads(base64decode(response["client_info"]))
126-
if "client_info" in response
127-
else { # ADFS scenario
124+
client_info = {}
125+
if "client_info" in response: # We asked for it, and AAD will provide it
126+
client_info = json.loads(base64decode(response["client_info"]))
127+
elif id_token_claims: # This would be an end user on ADFS-direct scenario
128+
client_info = {
128129
"uid": id_token_claims.get("sub"),
129130
"utid": realm, # which, in ADFS scenario, would typically be "adfs"
130131
}
131-
)
132-
home_account_id = "{uid}.{utid}".format(**client_info)
132+
home_account_id = ( # It would remain None in client_credentials flow
133+
"{uid}.{utid}".format(**client_info) if client_info else None)
133134
target = ' '.join(event.get("scope", [])) # Per schema, we don't sort it
134135

135136
with self._lock:

0 commit comments

Comments
 (0)