I am also in the same boat. I have tried everything but can’t get simple thing in the access token.
(I am using React SPA)
My Rule looks like:
function addEmailToAccessToken(user, context, callback) {
// This rule adds the authenticated user's email address to the access token.
var namespace = 'https://dev-xxx.us.auth0.com/';
console.log("I am here", "at: ", context.accessToken, "it: ", context.idToken);
if (context.accessToken) {
context.accessToken[namespace + 'email'] = user.email;
}
if (context.idToken) {
context.idToken[namespace + 'email'] = user.email;
}
return callback(null, user, context);
}
I can see the rule is fired only when when user logs in (not every time when I call getAccessTokenSilently)
But also when it gets called, the context.accessToken and context.idToken are empty.
I am here at: {} it: {}
I have also tried using pre made template and even tried Action/Flows Can’t seem to get custom claims/attributes in access token.
Can anyone from Auth0 please help?