Skip to content

Commit 2296877

Browse files
committed
add a mechanism for refreshing the auth0 management API token when it expires
1 parent 07012ed commit 2296877

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

common/services/auth0management.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ def get_roles_for_user(self, user_id):
3030
{"Authorization": "Bearer " + self.access_token}}
3131
resp = requests.get(url, headers=heads)
3232
data = resp.json()
33+
if (data.get("statusCode") == 401 and "xpired token" in data.get("message")):
34+
self.access_token = self.get_token()
35+
return self.get_roles_for_user(user_id)
3336
return data
3437

3538

0 commit comments

Comments
 (0)