passport-auth0: user_id is missing in profile

Hi,

i just did the nodejs/express quickstart for auth0. It seems like the user_id property is missing in req.user after a use authenticated.

const strategy = new Auth0Strategy(
  {
    domain: '',
    clientID: '',
    clientSecret: '',
    callbackURL: process.env.AUTH0_CALLBACK_URL || 'http://localhost:3000/callback',
    scope: 'openid profile email'
  },
  function(accessToken, refreshToken, extraParams, profile, done) {
    console.log(profile.user_id);   // This is undefined
    return done(null, profile);
  }
);

The docs about the profile clearly states that user_id is always available in the normalize profile: https://auth0.com/docs/user-profile/user-profile-details#normalized-user-profile

This is what i get when i print out the profile object:

{
  "displayName": "Andre Uschmann",
  "name": {
    "familyName": "Uschmann",
    "givenName": "Andre"
  },
  "picture": "https://lh5.googleusercontent.com/-KymPmQzSHZA/AAAAAAAAAAI/AAAAAAAAAAA/CSvKv_F1Xy8/photo.jpg",
  "locale": "de",
  "nickname": "andre.uschmann",
  "gender": "male",
  "_json": {
    "sub": "google-oauth2|116203000818893399355",
    "name": "Andre Uschmann",
    "given_name": "Andre",
    "family_name": "Uschmann",
    "nickname": "andre.uschmann",
    "picture": "https://lh5.googleusercontent.com/-KymPmQzSHZA/AAAAAAAAAAI/AAAAAAAAAAA/CSvKv_F1Xy8/photo.jpg",
    "gender": "male",
    "locale": "de",
    "updated_at": "2017-08-02T06:45:28.070Z"
  },
  "_raw": "{\"sub\":\"google-oauth2|116203000818893399355\",\"name\":\"Andre Uschmann\",\"given_name\":\"Andre\",\"family_name\":\"Uschmann\",\"nickname\":\"andre.uschmann\",\"picture\":\"https://lh5.googleusercontent.com/-KymPmQzSHZA/AAAAAAAAAAI/AAAAAAAAAAA/CSvKv_F1Xy8/photo.jpg\",\"gender\":\"male\",\"locale\":\"de\",\"updated_at\":\"2017-08-02T06:45:28.070Z\"}"
}

It seems like the user_id is stored in profile._json.sub? But this is nowhere mentioned in the docs.

Am i missing something?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (2 by maintainers)

Most upvoted comments

anyway, @uschmann - if you want to use my fixed version, replace the dependency in package.json with

    "passport-auth0": "FrontierFoundry/passport-auth0"

(edit: updated the above to use non-ssh link)

fixed in 0.6.1! Sorry about the bumps, folks! We’re discussing internally if we either move this project forward or start recommending another project for OIDC clients. I’ll let you know.