Sailsjs jwt token authentication example

I follow this tutorial .

But when I do sails liftto launch my application, I get below the error.

throw new TypeError ('JwtStrategy requires the function to retrieve jwt from requests (see the jwtFromRequest option)'); ^

TypeError: JwtStrategy requires a function to retrieve jwt from requests (see jwtFromRequest parameter)

Please help me resolve this error.

+4
source share
1 answer

JwtStrategy, github, jwtFromRequest, , -jwt.

:

var ExtractJwt = require('passport-jwt').ExtractJwt;
var JWT_STRATEGY_CONFIG = {
  jwtFromRequest: ExtractJwt.fromAuthHeader(),
  secretOrKey: SECRET,
  issuer : ISSUER,
  audience: AUDIENCE,
  passReqToCallback: false
};

,

+9

Source: https://habr.com/ru/post/1629680/


All Articles