I can't add the user email on access_token

I tried adding user access by following the following topics:
tutorial 1

tutorial 2

But when I try to login to some user using this tutorial: Get access token using the email + password

The access token that I get doesn’t contain the user’s email.

Am I doing something wrong?

Hi there @joaomarcelo welcome to the community!

It’s hard to know exactly what the issue could be, but if you are not getting the email claim back in the Access Token then something is off - Might I suggest that you take a look at using Actions instead? In particular, you will want to look at utilizing a Post Login Action, something like this:

exports.onExecutePostLogin = async (event, api) => {
  // This adds the authenticated user's email address to the access token.
  if (event.authorization) {
    const namespace = 'https://MY_DOMAIN_DOT_COM';
    api.accessToken.setCustomClaim(`${namespace}/claims/email`, event.user.email);

Let us know if that doesn’t do the trick!

1 Like

Thanks a lot!
The Post login action works! :metal:

1 Like

Awesome! Happy to hear that and thanks for confirming :metal:

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