Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support userInfo endpoint #179

Open
ThallesP opened this issue Oct 19, 2023 · 1 comment
Open

Support userInfo endpoint #179

ThallesP opened this issue Oct 19, 2023 · 1 comment

Comments

@ThallesP
Copy link

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.

@Niewdanka
Copy link

@jaredhanson Hi! Any chances to add this functionality. We receive accessToken that can be pass to _oauth2.get() function like in google_auth20 package.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants