Getting grantor/profile picture from userid?

Is it possible to get the gravator or the default profile picture if I have a user id? I don’t want to make another rest call just to display the user profile picture.

I keep track of user ids in my local database, not auth0, which are part of a team.When it comes to displaying the team members belonging to a team, I rather not make n number of calls to auth0 to get the default picture.

Any ideas?

Hi @iJKTen,

I’m not sure what your app architecture looks like, but in most cases, Auth0 will pass your app an Access Token (used for making API requests) and an ID Token after authentication. The ID Token will have the user’s picture and other info for your frontend to use.

Depending on which Auth0 SDK you are using, you can retrieve the claims from the user similar to this example from the React SDK:

import { useAuth0, withAuthenticationRequired } from "@auth0/auth0-react";

export const ProfileComponent = () => {
  const { user } = useAuth0();
  return (
    <div>
      <img
        src={user && user.picture}
        alt="Profile"
        className="rounded-circle img-fluid profile-picture mb-3 mb-md-0"
      />
    </div>)
}

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