Skip to content

Support userInfo endpoint #179

@ThallesP

Description

@ThallesP

Hi @jaredhanson, I see that the profile params are empty for me, would be possible to populate that with the userInfo endpoint?

Most of OAuth2 providers (keycloak for example) supports that endpoint.

I was thinking of something like this:

passport.use(new OAuth2Strategy({
    authorizationURL: 'https://www.example.com/oauth2/authorize',
    tokenURL: 'https://www.example.com/oauth2/token',
    userInfo: "https://www.example.com/oauth2/userinfo",
    clientID: EXAMPLE_CLIENT_ID,
    clientSecret: EXAMPLE_CLIENT_SECRET,
    callbackURL: "http://localhost:3000/auth/example/callback"
  },
  function(accessToken, refreshToken, profile, cb) {
    console.log(profile) // output: {<...>}
    User.findOrCreate({ exampleId: profile.id }, function (err, user) {
      return cb(err, user);
    });
  }
));

I would like to make a PR request if that's fine for you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions