Home > other >  password authentication token / Nodejs - Express JWT
password authentication token / Nodejs - Express JWT

Time:11-02

I'm having trouble logging into the server to do the authentication tests for my JWT password token, it claims problem

no " required:jwt({"

grateful to whoever helps me enter image description here enter image description here

user side of authentication enter image description here

I tried changing the commas but the problem persisted I believe it is something deeper

CodePudding user response:

You should require the library with a different syntax, reading documentation:

const { expressjwt: jwt } = require("express-jwt")

Also, it looks that the algorithms property is a required option. Therefore, on line 20 and 25 of your code, you want to write something like:

jwt({secret:'secret', algorithms: ["HS256"], userProperty: 'payload', getToken: getTokenFromHeader)

The above example just works. Of course you should choose the right strategy and the right algorithm for a strong authentication.

CodePudding user response:

const { expressjwt: jwt } = require("express-jwt");
  • Related