# If the idtype is user, use the unique_name or upn
94
+
# If the idtype is app, use the app_displayname or appid
95
+
if "idtyp" in decoded_accesstoken and decoded_accesstoken["idtyp"] == "user":
96
+
user = decoded_accesstoken["unique_name"] if "unique_name" in decoded_accesstoken else decoded_accesstoken["upn"] if "upn" in decoded_accesstoken else "unknown"
97
+
elif "idtyp" in decoded_accesstoken and decoded_accesstoken["idtyp"] == "app":
98
+
user = decoded_accesstoken["app_displayname"] if "app_displayname" in decoded_accesstoken else decoded_accesstoken["appid"] if "appid" in decoded_accesstoken else "unknown"
# If the idtype is user, use the unique_name or upn
159
+
# If the idtype is app, use the app_displayname or appid
160
+
if "idtyp" in decoded_accesstoken and decoded_accesstoken["idtyp"] == "user":
161
+
user = decoded_accesstoken["unique_name"] if "unique_name" in decoded_accesstoken else decoded_accesstoken["upn"] if "upn" in decoded_accesstoken else "unknown"
162
+
elif "idtyp" in decoded_accesstoken and decoded_accesstoken["idtyp"] == "app":
163
+
user = decoded_accesstoken["app_displayname"] if "app_displayname" in decoded_accesstoken else decoded_accesstoken["appid"] if "appid" in decoded_accesstoken else "unknown"
150
164
save_refresh_token(
151
165
response.json()["refresh_token"],
152
166
f"Created using refresh token {refresh_token_id}",
# If the idtype is user, use the unique_name or upn
228
+
# If the idtype is app, use the app_displayname or appid
229
+
if "idtyp" in decoded_accesstoken and decoded_accesstoken["idtyp"] == "user":
230
+
user = decoded_accesstoken["unique_name"] if "unique_name" in decoded_accesstoken else decoded_accesstoken["upn"] if "upn" in decoded_accesstoken else "unknown"
231
+
elif "idtyp" in decoded_accesstoken and decoded_accesstoken["idtyp"] == "app":
232
+
user = decoded_accesstoken["app_displayname"] if "app_displayname" in decoded_accesstoken else decoded_accesstoken["appid"] if "appid" in decoded_accesstoken else "unknown"