Passport-jwt Unauthorized

后端 未结 2 708
一向
一向 2021-01-15 13:28

I\'m New to node js. I\'m using passport jwt for authentication. When i tried to authenticate, its always showing \"unauthorized\".

my passport.js file

相关标签:
2条回答
  • 2021-01-15 14:08

    I found out the issue, In new passport-jwt updates, we have to use

    opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('jwt');
    
    0 讨论(0)
  • 2021-01-15 14:08

    if you are using opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken(); as your jwtFromRequest then your Authorization header is like

    bearer xxxxx.yyyyy.zzzzz

    you can check the BEARER_AUTH_SCHEME specified in the extract_jwt.js located in the passport-jwt/lib folder


    if you are using opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('jwt') as your jwtFromRequest then your Authorization header is like

    JWT xxxxx.yyyyy.zzzzz

    you can check the LEGACY_AUTH_SCHEME specified in the extract_jwt.js located in the passport-jwt/lib folder

    0 讨论(0)
提交回复
热议问题