首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >400 BadRequest:缺少凭据feathersjs身份验证-本地

400 BadRequest:缺少凭据feathersjs身份验证-本地
EN

Stack Overflow用户
提问于 2018-04-29 16:14:57
回答 2查看 741关注 0票数 0

我正在尝试使用@feathersjs/authentication-local对用户进行身份验证,尽管我给出了正确的用户名和密码,但我得到了以下响应

代码语言:javascript
复制
{
    "name": "BadRequest",
    "message": "Missing credentials",
    "code": 400,
    "className": "bad-request",
    "data": {
        "message": "Missing credentials"
    },
    "errors": {}
}

user实体的DB属性为username & password。我的配置如下

代码语言:javascript
复制
const settings = {
    secret: 'super&secret',
    usernameField: 'username',
    passwordField: 'password',
    entityUsernameField: 'username',
    entityPasswordField: 'password'
};

app.configure(authentication(settings))
        .configure(local());

app.service('authentication').hooks({
        before: {
            create: [authentication.hooks.authenticate(['local', 'jwt'])],
            remove: [],
        }
    });

我已经在请求正文中添加了"strategy": "local"。我遗漏了什么?请帮帮忙。

EN

回答 2

Stack Overflow用户

发布于 2018-04-30 02:29:09

这通常发生在没有注册Express bodyParser中间件的情况下。如feathers-chat所示,它必须是set up before authentication

票数 0
EN

Stack Overflow用户

发布于 2018-07-10 19:38:39

缺少凭据feathersjs身份验证-本地,可能由于以下原因而发生此错误:

  1. 发送请求时缺少字段。通常,如果存在任何数据,它都会抛出一个错误: Invalid NotAuthenticated: Invalid login if the credentials is not correct.
  2. Escape field in default.json,以避免引用系统环境变量。Refer to this.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50084624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档