Trying to implement JWT authentication in node. Getting unauthorized in protected routes

后端 未结 2 1546
广开言路
广开言路 2021-01-24 18:55

I am trying to implement JWT authentication. /login and /register work fine and they return authentication token, but when I try to GET /secret with a header \'Authorization\' =

相关标签:
2条回答
  • 2021-01-24 19:33

    Got it. Made a mistake in the request.

    As per the README, it should be 'Authorization' = 'bearer token_received_on_login'

    0 讨论(0)
  • 2021-01-24 19:45
    opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken();
    

    should be

    ExtractJwt.fromAuthHeaderWithScheme('jwt');
    
    0 讨论(0)
提交回复
热议问题