护照-oauth2授权URL和令牌URL实现

时间:2020-05-25 06:45:34

标签: node.js oauth-2.0 passport.js

我正在将 passport-oauth2 用于Oauth2,并且由于没有官方文档中的任何信息,所以在实现authenticationURL和TokenURL时感到困惑。

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);
    });
  }
));

0 个答案:

没有答案