Get user profile in python with access token

I was previously using the nodejs library to get the user profile with an access token, like this

// Initialize the Auth0 client
var AuthenticationClient = require('auth0').AuthenticationClient;
var auth0 = new AuthenticationClient({
    domain: functions.config().familybank.auth0.domain,
    clientID: functions.config().familybank.auth0.clientid
});

var getUserInfo = async (token) => {
    var userInfo = auth0.getProfile(token)
    .catch( function(err) {
        console.error('Error getting userProfile from Auth0: ' + err);
        conv.close("Something went wrong. Please try again in a few minutes. " + err)
    });
    return userInfo;
}

I shifted to python and I’m trying to figure out how to do the same thing. Most of the examples I see are how to have my python web application do authentication, so I’m not sure if this is normally done in Python.

Is this possible in Python? Are there any examples?

I found the following works

from auth0.v3.authentication import Users

domain = 'myapp.auth0.com'

users = Users(domain)
myuser = users.userinfo("token")

print(myuser)
2 Likes

Thanks a lot @dwmaillist for sharing it with the rest of community!

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