0

I need to implement Oauth 2.0 in my node js app using passport.But Oauth 2.0 documentation in passport does not contain schema definition and user registration and refresh token.Is there any Restful API implementation in node js with passport similar to authentication mechanism in Laravel.

Shaju Nr
  • 338
  • 3
  • 18

2 Answers2

1

For REST API implementation with Node.js and passport.js oAuth 2.0, you can refer to this article. For more information, you can refer to this StackOverflow question.

Raj Thakar
  • 198
  • 9
0

Use passport-oauth2 for this,

npm install passport-oauth2

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

For more details refer Here

Vipin PS
  • 422
  • 4
  • 5