passport-oauth2
passport-oauth2 copied to clipboard
Support userInfo endpoint
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.
@jaredhanson Hi! Any chances to add this functionality. We receive accessToken that can be pass to _oauth2.get() function like in google_auth20 package.