# If the idtype is user, use the unique_name or upn
94
94
# If the idtype is app, use the app_displayname or appid
95
+
# Otherwise, use whatever we can get
95
96
if "idtyp" in decoded_accesstoken and decoded_accesstoken["idtyp"] == "user":
96
97
user = decoded_accesstoken["unique_name"] if "unique_name" in decoded_accesstoken else decoded_accesstoken["upn"] if "upn" in decoded_accesstoken else "unknown"
97
98
elif "idtyp" in decoded_accesstoken and decoded_accesstoken["idtyp"] == "app":
98
99
user = decoded_accesstoken["app_displayname"] if "app_displayname" in decoded_accesstoken else decoded_accesstoken["appid"] if "appid" in decoded_accesstoken else "unknown"
100
+
else:
101
+
user = decoded_accesstoken["unique_name"] if "unique_name" in decoded_accesstoken \
102
+
else decoded_accesstoken["upn"] if "upn" in decoded_accesstoken \
103
+
else decoded_accesstoken["app_displayname"] if "app_displayname" in decoded_accesstoken \
104
+
else decoded_accesstoken["oid"] if "oid" in decoded_accesstoken \