首页 > 解决方案 > 如何使用 express-oauth-server 进行身份验证?

问题描述

我想为我的应用程序使用 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

解决方案


我已经解决了,我?client_id=xxx在网址中丢失了。


推荐阅读