Please include the following information in your post:
Which SDK this is regarding: e.g. @auth0/auth0-react
SDK Version: 1.2.0
Platform Version: e.g. Npm 6.14.8
I have roles assigned via rules to id_token. When a new user signs in (google auth or sign up page) we don’t get the roles assigned in id_token or the user object. getAccessTokenSilently({ ignoreCache: true }); works around the problem of id_token not having the claims. As of 1.2.0 changelist states that user object is also updated when getAccessTokenSilently is called, however, it’s not updated with roles. Any help would be appreciated.
I took a look at the rule via our internal tools, and it looks like callback(null, user, context); is being called at the bottom of the rule before the async management.users.assignRoles method completes.
If you remove the last callback(null, user, context); at the bottom of the rule, the user’s roles should be included in the ID Token.
You were right, I forgot the last callback, which ran before the reply from assignRoles to management api. Which fixed the role issue, however, now I don’t get the user_metadata which I see when I test the rules script. I don’t see anything obvious unfortunately.
Just to double check that the user has metadata, when you go to Users & Roles (or User Management) in your dashboard and click on the new user, do they have any user_metadata?
Now I added the same rule one more time, which fixed getting the user_metadata on the second login (redirect after signup still doesn’t give the user_metadata object in the token) It looks like this full e2e flow needs to be tested on your side, Please let me know if I can provide anything.