Get current changes for custom claims while user is logging in

I am using universal login (using next.js auth0 package).
Currently when user signup, it can get the user id but when i update the user metadata. It did not get the newest data. I tried to call "handleProfile({refetch: true}). It did not work.

I decide to login again (without prompt), it is working.
Is this correct way to do that? Is there another way to solve this?

Hey there,

Do you refer to access token that consist of the “sub” claim with the user id value? Or the token ID?

How do you currently update the user metadata?

To add the additional claims to the ID or Access tokens, you can use actions, in the case of the access token it would be the api.accessToken.setCustomClaim method.


I mean “sub” claim.

Now i am using API to update the user metadata.

About application:
User register to create an workspace. I will have to assign a unique ID to it. In future ,it can have more people to access the workspace.

Note: To get the custom claims, i add actions to get the custom claims after login.

Current flow:

  1. User sign up using universal login
  2. I call my api (/register) to assign a workspace ID and update the custom claims.
  3. User still on current session. It cannot get the latest custom claims. To solve this issue. I trigger login(without prompt).
  4. Now if i called:
const {user} = useUser();

It can get the latest the custom claims.

Before i come up with this approach, i try to run handleProfile({refetch: true}) after step 2. It could not get the latest custom claims.

While writing this, i realise my mistake. What i would do is to assign the workspace ID after signup using actions. and trigger the login(without prompt).


1 Like

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