HomeTutorsContact

(Solved) How to fix UnauthorizedError No authorization token was found?

By Gulshan Saini
Published in NodeJS
August 29, 2020
1 min read

While using package express-jwt, I faced issue UnauthorizedError No authorization token was found

Below is stack trace of same

Error

UnauthorizedError: No authorization token was found
    at middleware (/server/node_modules/express-jwt/lib/index.js:79:21)
    at Layer.handle [as handle_request] (/server/node_modules/express/lib/router/layer.js:95:5)
    at next (/server/node_modules/express/lib/router/route.js:137:13)
    ...

Solution

Add Authorization header while sending request with value of Bearer <token>. Replace <token> with jwt token. Make sure you have space between Bearer and <token>

curl --location --request GET 'http://localhost:8000/api/user/5f47eaaada0785698c571b68' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZjQ3ZWFhYWRhMDc4NTY5OGM1NzFiNjgiLCJpYXQiOjE1OTg2MTMyMTYsImV4cCI6MTU5OTIxODAxNn0.yHkKewj4oyPZK9hTY6gR7us8zfvW5L7z6UxmLXfy8H0' \
--data-raw ''

Tags

#express#express-jwt
Previous Article
(Solved) How to fix error algorithms should be set express-jwt?

Related Posts

NodeJS
(Solved) How to fix UnauthorizedError invalid algorithm?
August 30, 2020
1 min
Gulshan Saini

Gulshan Saini

Fullstack Developer

Topics

Angular
JavaScript
ReactJS
Typescript

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.
© 2021, All Rights Reserved.

Quick Links

Contact UsBrowserCSSPythonPuppeteer

Social Media