【问题标题】:Implement Oauth 2.0 authentication mechanism using passport使用护照实现 Oauth 2.0 认证机制
【发布时间】:2018-07-23 09:38:30
【问题描述】:

我需要使用护照在我的节点 js 应用程序中实现 Oauth 2.0。但是护照中的 Oauth 2.0 文档不包含架构定义和用户注册和刷新令牌。节点 js 中是否有任何带有类似于身份验证机制的护照的 Restful API 实现在 Laravel 中。

【问题讨论】:

    标签: node.js oauth passport.js


    【解决方案1】:

    关于 Node.js 和 passport.js oAuth 2.0 的 REST API 实现,您可以参考this 文章。更多信息可以参考this StackOverflow question.

    【讨论】:

      【解决方案2】:

      为此使用passport-oauth2,

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

      更多详情请咨询Here

      【讨论】:

        猜你喜欢
        • 2017-08-19
        • 2022-12-24
        • 2014-07-28
        • 2012-09-17
        • 1970-01-01
        • 1970-01-01
        • 2022-08-05
        • 1970-01-01
        • 2012-04-17
        相关资源
        最近更新 更多