HomeTutorsContact

(Solved) How to fix UnauthorizedError invalid algorithm?

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

While using package express-jwt, I faced issue UnauthorizedError invalid algorithm

Below is stack trace of same

Error

UnauthorizedError: invalid algorithm
    at /server/node_modules/express-jwt/lib/index.js:105:22
    at /server/node_modules/jsonwebtoken/verify.js:121:14
    at getSecret (/server/node_modules/jsonwebtoken/verify.js:90:14)
    at Object.module.exports [as verify] (/server/node_modules/jsonwebtoken/verify.js:94:10)
    at verifyToken (/server/node_modules/express-jwt/lib/index.js:103:13)
    ...

Solution

Add algorithms property in expressJwt options as follows

expressJwt({
  secret: process.env.JWT_SECRET,
  algorithms: ['sha1', 'RS256', 'HS256'],
})

Tags

#express#express-jwt
Previous Article
(Solved) How to fix UnauthorizedError No authorization token was found?

Related Posts

NodeJS
(Solved) How to fix UnauthorizedError No authorization token was found?
August 29, 2020
1 min
Gulshan Saini

Gulshan Saini

Fullstack Developer

Topics

JavaScript
Angular
ReactJS
Typescript
Linux

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Quick Links

Contact UsBrowserCSSPythonPuppeteer

Social Media