Storing a user's permissions when they login


I’m trying to use auth0 with Flask and Python to have users login and then restrict their behaviours according to their permissions. I am following the tutorial to have them login but cannot figure out how to store the permissions of a logged in user.

At the moment I am creating an auth0 object like below:

auth0 = oauth.register(
    'scope': 'openid profile email',

Then i am having the user login like this:

def login():
    return auth0.authorize_redirect(redirect_uri='YOUR_CALLBACK_URL')

And my callback looks like this:

# Here we're using the /callback route.
def callback_handling():
# Handles response from token endpoint
resp = auth0.get('userinfo')
userinfo = resp.json()

# Store the user information in flask session.
session['jwt_payload'] = userinfo
session['profile'] = {
    'user_id': userinfo['sub'],
    'name': userinfo['name'],
    'picture': userinfo['picture']
return redirect('/dashboard')

How do I edit the callback so that it also stores permissions information in the session object? (Or is there a different better way of storing the permissions of a user?) . I’ve tried to see if the permissions are stored in the auth0 object but I can’t seem to find them there.

Note that I have definitely set my application settings so that the JWT returns information about the permissions so that’s not the problem.



Hi @p.christodoulou2,

Welcome to the Auth0 Community Forum!

Just to clarify, you have received the user permissions in the access token, and are wondering how to reference them? If so, you could add them in the session, or just reference the token whenever you need to see the permissions.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.