0

I'm trying to authenticate a user using @feathersjs/authentication-local, Though I'm giving proper username & password, I get following response

{
    "name": "BadRequest",
    "message": "Missing credentials",
    "code": 400,
    "className": "bad-request",
    "data": {
        "message": "Missing credentials"
    },
    "errors": {}
}

DB property of user entity is username & password. My configuration is as following

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: [],
        }
    });

I've added "strategy": "local" on request body. What am I missing? Please help.

ARiF
  • 1,079
  • 10
  • 23

2 Answers2

0

This usually happens when there is no Express bodyParser middleware registered. As shown in the feathers-chat it has to be set up before authentication.

Daff
  • 43,734
  • 9
  • 106
  • 120
  • Actually @Daff, I had the bodyParser middleware and registered before the authentication hooks. Lately I used feathers generator to create the authentication service which was successful. I assume there was some conflict at `default.json`. In my service & schema model name is `users` but i had to use `"entity": "user"` in `default.json` – ARiF May 07 '18 at 20:48
0

Missing Credential feathersjs authentication-local, this error may occur due to following reasons:

  1. You are missing fields when sending the request. Usually, if there is any data present it throws an error as NotAuthenticated: Invalid login if the credentials are not correct.

  2. Escape fields in default.json to avoid referring to system environmental variables. Refer to this.

Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58