Server-side currentUser email

I’m using Auth0 for authentication. I’m trying to find currentUser.email field. I want to save this email for potential future migration. It looks like the object does not have the email field. Here’s an example data for currentUser:

{
  iss: 'https://dev-4-ozihdc.auth0.com/',
  sub: 'auth0|5ee53543e4647b00137025dd',
  aud: [
    'https://dev-4-ozihdc.auth0.com/api/v2/',
    'https://dev-4-ozihdc.auth0.com/userinfo'
  ],
  iat: 1592079735,
  exp: 1592166135,
  azp: 'RFI3tsaUePpAMtVv9u3Td07eejT6BTiL',
  scope: 'openid profile email'
}

I see the email field in currentUser on the client-side, but not the server-side. How do I retrieve it on the server-side?

You can add it to the jwt by using Auth0’s rules as described over here: https://community.auth0.com/t/email-address-missing-in-access-token-when-using-google-cloud-endpoint/11444/5

We should probably add this to the Redwood’s Auth docs!

1 Like

@peterp thanks very much. I figured it out now. It is confusing as the rule needs to be added inside Auth0 Auth Pipeline. I was trying to add it into getCurrentUser function. :slight_smile:

2 Likes

Potentially related with a different take on the setup (just fyi):

1 Like