Skip to content

User Profile

After login, the user object from useAuth contains two parts:

const { user } = useAuth();
// Claims from the ID token (always available after login)
user?.claims.sub; // Subject identifier
user?.claims.iss; // Issuer
user?.claims.aud; // Audience
user?.claims.exp; // Expiration (Unix timestamp)
user?.claims.iat; // Issued at (Unix timestamp)
// Profile from the UserInfo endpoint (fetched separately)
user?.profile?.email;
user?.profile?.name;
user?.profile?.preferred_username;
  • Claims come from the ID token. They’re decoded locally (no network request) and contain identity assertions from the IdP.
  • Profile comes from the UserInfo endpoint (GET /userinfo). It requires a network request with the access token and contains the full user profile.

By default, AuthProvider fetches the user profile after login. You can disable this:

<AuthProvider config={config} fetchProfile={false}>
<App />
</AuthProvider>

When fetchProfile is false:

  • user.claims is still available (decoded from the ID token)
  • user.profile is null
  • No request is made to the UserInfo endpoint

This is useful when you only need the sub claim for API calls and don’t need display information.

If you disabled automatic profile fetching, you can fetch it on demand:

const { user, actions } = useAuth();
async function loadProfile() {
await actions.fetchProfile();
// user.profile is now populated
}

The profile fields depend on the scopes you requested and what the IdP returns:

ScopeFields
openidsub
profilename, preferred_username, picture, etc.
emailemail, email_verified