Skip to content

Commit 25472a3

Browse files
committed
Changing home account id to sub from idtoken claims
1 parent 1e53642 commit 25472a3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

msal/token_cache.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,16 @@ def add(self, event, now=None):
124124
client_info = {}
125125
if "client_info" in response: # We asked for it, and AAD will provide it
126126
client_info = json.loads(base64decode(response["client_info"]))
127+
home_account_id = (
128+
# It would remain None in client_credentials flow
129+
"{uid}.{utid}".format(**client_info) if client_info else None)
127130
elif id_token_claims: # This would be an end user on ADFS-direct scenario
128131
client_info = {
129132
"uid": id_token_claims.get("sub"),
130-
"utid": realm, # which, in ADFS scenario, would typically be "adfs"
131133
}
132-
home_account_id = ( # It would remain None in client_credentials flow
133-
"{uid}.{utid}".format(**client_info) if client_info else None)
134+
home_account_id = (
135+
"{uid}".format(**client_info))
136+
134137
target = ' '.join(event.get("scope", [])) # Per schema, we don't sort it
135138

136139
with self._lock:

0 commit comments

Comments
 (0)