Auth Error after updating app_metadata via Management API and injecting metadata to IdToken

Hi guys, following “thread”. I have a similar issue but in this case i am updating user_metadata and adding the metadata to IdToken in a rule.

Is this happening because the token get modified? I am not updating email_verified in my case.

Regards and thank you

Thread: Silent Auth errors with Login Required after updating app_metadata via Management API

Hi @gmjun2000,

Welcome to the Auth0 Community!

Before we continue, could you please elaborate what are the errors you are getting?

And, could you please share your Rule for adding the user_metadata to the ID Token?

Thank you.

Hi @rueben.tiow thank you for your response.
With checkSession({ ignoreCache: true }) just log me out and getTokenSilently({ ignoreCache: true }) i get Login required.

My rule:

function migrateRootAttributes(user, context, cb) {
  var namespace = "https://e4s.systems/"; 
  context.idToken[namespace + "metadata"] = user.user_metadata;
  context.accessToken[namespace + "metadata"] = user.user_metadata;
  cb(null, user, context);
 
}

Hi @gmjun2000,

Thank you for your reply.

First, the Login required error is expected when using the getTokenSilently method when there isn’t an authenticated user. In silent authentication, the “login required” error is thrown when the user’s browser does not or cannot send the “Auth0” cookie. This cookie identifies the user’s logged-in session with Auth0 and resides on the client’s browser.

In this case, you’ll need to initiate the authentication process again.

As for your Rule, it is correct for appending custom claims to tokens and should work.

Please let me know if there’s anything else I can do to help.

Thank you.

Hi @rueben.tiow. What could be the reason why i get revoked the token? The token is fresh and recently created.

Hi @gmjun2000,

Thank you for your response.

I have made an edit to my previous post. The error you have encountered happens because it expects an authenticated user when using the getTokenSilently method.

As a result, you will need to make sure the user is logged in, or you will need to reinitiate the log-in process. Additionally, you might want to avoid the checkSession({ ignoreCache: true }) logging you out preceding the getTokenSIlently method.

Hoped this helps!

Please let me know if there’s anything else I can do to help.

Thanks.

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