【问题标题】:How to authenticate with express-oauth-server?如何使用 express-oauth-server 进行身份验证?
【发布时间】:2021-05-04 02:15:01
【问题描述】:

我想为我的应用使用 nodejs 实现一个 oAuth2 服务器,我正在使用https://niceprogrammer.com/express-js-oauth-2-server-using-oauth2-server-package/ 上的教程

但是,当我转到 https://localhost:3000/oauth/authenticate (登录路径)并尝试登录时,我得到一个 json 响应:{"error":"invalid_request","error_description":"Missing parameter: `client_id`"}

负责鉴权的函数如下:

router.post('/oauth/authenticate', async (req, res, next) => {

    let UserModel = mongoose.model('User');
    req.body.user = await UserModel.findOne({ username: req.body.username });

    return next();
}, oauth.authorize({
    authenticateHandler: {
        handle: req => {
            return req.body.user;
        }
    }
}));

教程有问题还是我做错了什么?

【问题讨论】:

    标签: node.js


    【解决方案1】:

    我已经解决了,我在网址中缺少?client_id=xxx

    【讨论】:

      猜你喜欢
      • 2011-10-20
      • 2014-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多