Skip to content
Prev Previous commit
Next Next commit
Fix regression on credential client grant
  • Loading branch information
rayluo committed Jul 20, 2019
commit 6490e1826344854465ed4c5265c42df70f941ccf
13 changes: 7 additions & 6 deletions msal/token_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,16 @@ def add(self, event, now=None):
id_token_claims = (
decode_id_token(id_token, client_id=event["client_id"])
if id_token else {})
client_info = (
json.loads(base64decode(response["client_info"]))
if "client_info" in response
else { # ADFS scenario
client_info = {}
if "client_info" in response: # We asked for it, and AAD will provide it
client_info = json.loads(base64decode(response["client_info"]))
elif id_token_claims: # This would be an end user on ADFS-direct scenario
client_info = {
"uid": id_token_claims.get("sub"),
"utid": realm, # which, in ADFS scenario, would typically be "adfs"
}
)
home_account_id = "{uid}.{utid}".format(**client_info)
home_account_id = ( # It would remain None in client_credentials flow
"{uid}.{utid}".format(**client_info) if client_info else None)
target = ' '.join(event.get("scope", [])) # Per schema, we don't sort it

with self._lock:
Expand Down