Questions tagged [express-jwt]

Connect/express middleware that validates a JsonWebToken (JWT) and set the req.user with the attributes

Middleware that validates JsonWebTokens and set req.user.

This module lets you authenticate HTTP requests using JWT tokens, in your Node.js applications. JWT tokens are typically used protect API endpoints, and are often issued using OpenID Connect.

GitHub: https://github.com/auth0/express-jwt

375 questions
3
votes
2 answers

Authorization type Bearer Token on Postman

I'm trying test a few endpoints using Postman. All endpoint, require a token which can be obtain by log-in. So I did this : Request #1 After login success, I have access to the token from the response, then I store that token in my global…
code-8
  • 54,650
  • 106
  • 352
  • 604
3
votes
1 answer

node expressJwt unless specify id route

We are using the expressJwt library and I want to be able to exclude the GET for the following route api/items/:id but not include any routes that look like api/items/:id/special-action. So far, I've only been able to exclude all routes that have…
user3331142
  • 1,222
  • 1
  • 11
  • 22
3
votes
0 answers

React-redux and React Native error handling for expired JWT

I have a system where the authentication is based around JWT. I have a JWT auth token, and a refresh token on the client. The refresh token is stored in the database on the server, and is used to refresh the JWT once the JWT expires every 12 hours -…
JamesG
  • 2,018
  • 2
  • 28
  • 57
3
votes
1 answer

How can i mock auth0 authentication for testing?

I am using autho0 and express-jwt in order to authenticate my app users. Everything is really cool besides the tests. The content that i pass in my API is strictly partitioned by authors. This means you can only access a content if you own it. I am…
Tiago Bértolo
  • 3,874
  • 3
  • 35
  • 53
3
votes
1 answer

How to redirect to unauthenticated user using express-jwt

This is my first express app. I am trying to implement authentication for some of the routes. Ideally, if users are not authenticated, they will be redirected to the home page. So I wrote this middleware: var jwt =…
Sydney
  • 1,349
  • 1
  • 14
  • 20
3
votes
1 answer

Adding JWT Token in Volley Request

I am using Node.js at the Backend, and need to send some params(parameters) and a jwt token(for authorization) in header of a GET request. I am using express-jwt module at the node server. The request need to be authorized using jwt token there.…
shikhar bansal
  • 1,629
  • 2
  • 21
  • 43
3
votes
2 answers

My authentication token interceptor does not intercept request/response of fresh route

I am trying to implement jwt authentication for my nodejs, express and angularjs app. So far I have generated the token, and stored it in my localStorage. According to this tutorial, I have implemented the authInterceptor in angular factory as…
Pravin
  • 1,671
  • 5
  • 23
  • 36
2
votes
1 answer

UnauthorizedError: No authorization token was found

In our backend routes/index.js, we have var auth = jwt({ secret: process.env.JWT_SECRET_KEY, userProperty: 'payload' }); ... ... router.get('/ask', auth, function (req, res, next) { ... ... } I tried to test the /ask api from the frontend…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
2
votes
3 answers

express-jwt - isRevoked : done is not a function

I am posting product only if user is Admin, everything is perfect, but unfortunately I am getting "done is not a function" when checking isRevoked token of user. Am I doing anything wrong to check if the user is Admin or not? I am using…
2
votes
4 answers

express-jwt isRevoked given 500 internal server error without any message

I am new in nodejs,expressjs and trying to authenticate routes using express-jwt package by creating a middleware. Everything is working fine with GET routes but when I am access POST routes and trying to revoke a token, it returns me 500 internal…
Mohd Hasan
  • 324
  • 1
  • 4
  • 17
2
votes
0 answers

invalid expiresIn option for string payload

I am trying to set the expiresIn function in my javascript app. I keep getting this error. Can anyone see what I am doing wrong? app.post('/login', async(req, res) => { const user = req.body.email; const accessToken =…
2
votes
1 answer

Where should I save jwt refresh token?

I used Nodejs Express and ejs and passprot jwt. I saved jwt token in the cookie by httpOnly the attribute. And before the page is rendered,router.get('/',isauth.verifyToken(), adminController.checkUser); ,check if the token is valid. If the token is…
rhrhgut
  • 57
  • 1
  • 7
2
votes
1 answer

Cannot set headers after they are sent to the client at ServerResponse.setHeader

Github : https://github.com/UJJWAL2001/Pro-Shop/tree/main/backend I am trying to use JWT token for protecting my routes via a middleware given below import jwt from 'jsonwebtoken' import User from '../models/userModel.js' import asyncHandler from…
2
votes
1 answer

UnauthorizedError: jwt audience invalid. expected:

I'm trying to use IdentityServer4 to protect my nodeAPI. export const jwtauth = jwt({ secret: jwksClient.expressJwtSecret({ cache: true, rateLimit: true, jwksRequestsPerMinute: 2, jwksUri:…
capiono
  • 2,875
  • 10
  • 40
  • 76
2
votes
2 answers

Where are JWT tokens stored in this example?

I am a beginner and recently started learning about authorization and authentication. So i came across JWT and started looking for tutorials how to implement it in node js. Appearantly there is a jwt middleware for nodejs called "jsonwebtoken". I…