Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
20 views

Passport JWT Unauthorized in node js and angular

I am using passport jwt with node and Angular. it is throwing unauthorized error. I have tried with many solution on other stackoverflow questions but nothing works. I am using sequalize with MySQL ...
Prasad Gavande's user avatar
0 votes
2 answers
158 views

Unknown authentication strategy "jwt" error in NestJS with Passport and JWT

I'm encountering an issue with my NestJS application that uses Passport and JWT for authentication. Initially, everything was working fine, but recently I started receiving the following error when ...
JDorozco's user avatar
0 votes
0 answers
15 views

contructor passportStrategy

I have a problem with my strategy for the acccess_token, it happens that if I don't pass anything to the constructor, the validate doesn't return anything, and if I pass something like this I don't ...
Javier Díaz Alfaro's user avatar
0 votes
0 answers
90 views

Access and refresh token management in nest js

Why when logging in through Postman it returns a refresh token and an access token, but when I log in again through Postman, it issues new refresh and access tokens? I think it's not a good practice ...
MUHAMMAD AWAIS's user avatar
0 votes
0 answers
30 views

Why I need to use passport JS

For example I have RolesGuard: import { CanActivate, ExecutionContext, ForbiddenException, Injectable, UnauthorizedException } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; import { ...
Морфей's user avatar
0 votes
0 answers
69 views

Trouble implementing a a passwordless login with a react spa as client

The api is built with nestjs. Here is the passport strategy and the respective controller: magic-link.strategy.ts import MagicLoginStrategy from 'passport-magic-login'; ... @Injectable() export class ...
ArcadeHero's user avatar
0 votes
1 answer
134 views

Auth Guard with JWT tokens in NestJS return 401 Unauthorized

I'm implementing JWT authentication and Role-Based Authorization in NestJS following this article When I signup and login, it works I get the access_token but when I try to use the token for ...
Krittikamas Sunophak's user avatar
0 votes
0 answers
38 views

Unable to get userInformation on frontend while using google Oauth2 with jwt and passport.js

I am using MERN stack for my project. Currently i am unable to display userinformation when sign in with google, I am able to save the data on database when i am signin locally and through google,but ...
AMAN Vijay's user avatar
0 votes
1 answer
62 views

Nest can't resolve dependencies of the AuthService

Error in NestJS: "Nest can't resolve dependencies of the AuthService (?, JwtService)." I am new to NestJS and I am trying to implement authentication with NestJS using JWT Token. However, ...
Muditha Madusith's user avatar
1 vote
2 answers
409 views

can't access validate function using nestjs jwt+passport auth

here's my study project codes. im trying to nestjs+jwt+passport. however, no matter what method i use, i get a 401 Unauthorized error. i cant even access the validate function, and when i try to ...
user23483412's user avatar
0 votes
1 answer
229 views

how to get raw jwt token in passport-jwt @nestjs/passport strategy?

this is my code. i want to get raw jwt token. import { HttpException, HttpStatus, Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { PassportStrategy } from '@...
nayounsang's user avatar
0 votes
0 answers
42 views

PassportJS, PassportJWT and Express - 401 Unauthorized

App.ts - This is done initially to setup the strategies. I have bodyParser before them and setup like shown. // for parsing application/x-www-form-urlencoded this.app.use(bodyParser.urlencoded({ ...
smb's user avatar
  • 589
1 vote
1 answer
217 views

Validating a token in Jwt strategy

I'm trying to validate a token but the validate function is not called from my token Strategy file and returns a 401 status code, here are my Auth module and my tokenStrategy: import { Module } from &...
tsiPlus's user avatar
  • 423
0 votes
1 answer
199 views

In NestJS and passport, how do I create an endpoint that accepts a valid or invalid JWT?

I'm using NestJS 10 with passport-jwt. I have a controller method in which the user can access whether or not they include a valid JWT in the Authorization header. If they include a JWT, I would ...
Dave's user avatar
  • 19.3k
0 votes
1 answer
84 views

JWTGuard always returning 401 unauthorized when using the correct token

I am a beginner in Nestjs When using JWTGuard in my user controller for all my CRUD operations it returns always 401 unauthorized error This is my JWT Strategy import { PassportStrategy } from "@...
Ahmed Adel's user avatar
0 votes
1 answer
25 views

How to authenticate user at multiple routes with token generated?

authRoute.post("/login", async (req, res) => { const response = await AuthController.signin(req.body); return res.send(response); }); authRoute.get( "/me", isAuth, ...
dmx's user avatar
  • 83
0 votes
1 answer
40 views

I am unable to accesse the authenticated routes in express js

In this when I try to access the api/test route I am redirected to the unauthorized section. // server.js const express = require('express'); const passport = require('passport'); const LocalStrategy =...
rasif sahl's user avatar
0 votes
1 answer
359 views

Nestjs using accessToken on another route return Unauthorized

Consider that I have two routes in NestJS, called "signUp" and "validate-code", both of which are inside the SignupModule. For the signUp route, I return an accessToken using JWT. ...
DolDurma's user avatar
  • 17.4k
0 votes
1 answer
975 views

NestJS - Passport JWT strategy does not attach user to request object

I am building an auth flow using NextAuth on a Next.js frontend, and Passport JWT on a NestJS + GraphQL backend. NextAuth gets a JWT token from a third party provider, and then attaches it to the auth ...
FlushBG's user avatar
  • 281
1 vote
0 answers
66 views

Authorizing issue with passport-jwt in a MERN project

I am experiencing a problem with passport jwt. Whenever i send a GET request adding authorization as Bearer <generated-token> in the header to the /profile route, i get a response which says &...
SharifMAbdullah's user avatar
1 vote
0 answers
27 views

PassportJS Auth with JWT and Goolge

So when I try to auth a user in the api with jwt or google the passport.authenticate redirects to google passport.authenticate(["jwt", "google"], { session: false, scope: ["...
Bernardo Rebelo's user avatar
1 vote
1 answer
1k views

NestJS AuthGuard JWT Auth0 constantly returns 401 unauthorized

I'm having trouble setting up Auth0 authentication using the passport-jwt library in a NestJS project. I've tried following the documentation, but I can't seem to get it to work. I'm not sure where I'...
LunarEC's user avatar
  • 13
2 votes
0 answers
332 views

JwtStrategy class is not working for cognito access token

I'm trying to validate the user access tokens by running them through my JwtStrategy class in nestjs. Besides my approach I've tried quite a few of the tutorial ones with no luck. I keep getting a 401 ...
erasmus's user avatar
  • 53
0 votes
2 answers
95 views

ReflectionClass $concrete is empty or null after upgrade to php8.0.8

Running php artisan passport:install after upgrading from php7.4 to php8.1 throws: Class "" not found error I have tried to bypass this error by checking for isClass before passing $...
user2991167's user avatar
0 votes
0 answers
1k views

Nestjs Passport google Oauth2 with custom JWT

What I need to achieve - I need to have a dynamic redirect URL (not google's refer Current Flow last step) based on the query param sent by Frontend. I need to send my custom JWT token instead of ...
Ishika Jain's user avatar
  • 1,177
2 votes
1 answer
842 views

Unauthorized 401 (Missing credentials) using Passport JWT in NestJS

I'm trying to use JWT to authenticate my users in my NestJS API but I always get the same error: Unauthorized 401. Let me show you my code before I tell you about my investigation that came up empty: ...
LoisDuplain's user avatar
0 votes
1 answer
846 views

How to get JWT payload from different key rather than req.user in NestJS

The way to get payload after the guard is like what this tutorial mentioned. @UseGuards(JwtAuthGuard) @Get('profile') getProfile(@Request() req) { return req.user; } Basically, you can access the ...
Chris Kao's user avatar
  • 503
2 votes
1 answer
45 views

(node:14224) UnhandledPromiseRejectionWarning

I am using below for JWT: let jwtoptions = {}; jwtoptions.jwtFromRequest = ExtractJWT.fromAuthHeaderAsBearerToken(); jwtoptions.secretOrKey = DB.secret; let Strategy = new JWTStrategy(jwtoptions,(...
AHF's user avatar
  • 1,072
1 vote
1 answer
386 views

Is there a way to differentiate a request rejection from a bad or non-existent token to a token expiration in NestJs Passport JWT?

I want to be able to differentiate the reason why my request was rejected in a NestJS Passport-JWT project. Now it's returning "401 - Request failed with status code 401" (ERR_BAD_REQUEST) ...
Nelson Teixeira's user avatar
2 votes
1 answer
1k views

How do I use asymmetric jwt validation in NestJs?

So my next step in NestJs is being able to use asymetric jwt validation with Passport. I've made it work with asymetric validation without using Passport and with symetric validation in Passport but ...
Nelson Teixeira's user avatar
0 votes
1 answer
1k views

JWT strategy (extended PassportStrategy) executes validate() method twice

I am trying to solve two issues in NestJS authentication/authorization. First issue is that validate() method is executed twice in a strategy (it doesn't matter which strategy is used, both are ...
scr4bble's user avatar
  • 309
1 vote
1 answer
291 views

How to manage refresh token in JWT Token method in express?

ex) refresh token: A acess Token : B user acquistion : A, B If B expires, use A to reissue B So if the attacker steals A, doesn't he get B? According to the rfc official documentation, I heard that ...
taehyun kang's user avatar
1 vote
2 answers
2k views

using passport-jwt in nest with secretOrKeyProvider option keep responsing http 401?

I am a new coder with nestjs, I want to use passport-jwt , nestjs/passport and firebase to build my app's authetication part, below are my codes. But I just got http 401 response, how can i fix it ? ...
Yan Zhihou's user avatar
0 votes
0 answers
196 views

Why does Passport-jwt return unauthorized error

I'm trying to make a very simple authentication scenario with passport-jwt. When I access a protected path, it keeps returning 'unauthorized'. I've tried almost everything suggested on similar threads ...
Vassis's user avatar
  • 21
0 votes
1 answer
855 views

Nestjs, Azure B2C endpoint guard to validate token

Good morning everyone, I wanted to ask this as I am new to Nest.js and haven't found an answer to my problem, I have an application that has the authentication from Azure B2C and I need to guard the ...
V. Benavides's user avatar
0 votes
1 answer
3k views

req.user if undefined in guards whileusing nest js + jwt + passport

I've implemented passport + jwt in my simple nestjs app for authentication. it's working fine. Now I want to use role-based authentication for routes but in my role.guard.ts , req.user is undefined. ...
UAhmadSoft's user avatar
1 vote
1 answer
2k views

JWT token does not expire

For whatever reason, the token generated by jsonwebtoken never expires. Here is my code so far. auth.ts Middleware. // Libs import { Express, Request, Response, NextFunction } from "express";...
Jplus2's user avatar
  • 2,531
1 vote
1 answer
171 views

How to config passport-jwt module? I have an error: Login sessions require session support

Hey there! I'm starting to learn Node.js courses and in one of it the guy making a registration and authentication with MEAN stack. But his code is old and not working today with updated modules. But ...
Hello World's user avatar
0 votes
1 answer
1k views

Change graphql context to http context

I have a global guard which is use for private routes and implemented with passport-jwt this guard works correctly in REST API but I have some graphql routes and when I send a request it gives the ...
Paiman Rasoli's user avatar
0 votes
1 answer
313 views

NestJS passport-jwt always throws Unauthorized

I encountered to the issue that whenever I sign up through the postman I receive the token. However, other route is private and requires token as Authorization Bearer, but whenever I put the token I ...
henrbu's user avatar
  • 208
1 vote
1 answer
2k views

Get user data in RoleGuard with passport JWT authentication

I've managed to get JWT authentication in my nestJS application. Now I want to implement the role guard and have therefore to check the role of the authenticated user. Therefore, I thought of ...
CAoT's user avatar
  • 192
0 votes
1 answer
1k views

Access response in passport strategy

I'm implementing an authentication with nestJS and passport. I have one token, with expiration date of 14 days, and a refreshTime of 15 minutes (inside the payload). So if the user makes a request ...
soroush madani's user avatar
4 votes
1 answer
6k views

How to manage multi-device simultaneous login with JWT tokens?

My query is regarding supporting multi-device login for the same user at the same time using JWT tokens. I am using NestJS as my backend. User table: userid, username, password(contains hashed ...
Kunal Karmakar's user avatar
1 vote
1 answer
2k views

Nestjs Passport-jwt better Unauthorized strategy

just going through docs on authentication in NestJS: docs.nestjs.com Here is the code: import { ExtractJwt, Strategy } from 'passport-jwt'; import { PassportStrategy } from '@nestjs/passport'; ...
momi's user avatar
  • 449
1 vote
0 answers
93 views

How to restrict page from logged-in user

I'm using Passport-jwt with Express. I'd liket to restrict pages from logged-in user by middle-ware. For example, I have a page, /dear-not-sign-in-user After a user logged-in, the user can't access ...
idpokute's user avatar
  • 608
1 vote
0 answers
1k views

nestjs logger logs undefined although the value is defined

I'm trying to create a custom @CurrentUser decorator to get the req.user set by the Passport JWT strategy. Confusingly, I get undefined when logging the req.user using NestJs's built-in logger and ...
Krissh's user avatar
  • 89
1 vote
1 answer
1k views

NestJS loosing request with Passport JWT strategy

In order to implement multitenancy in my NestJS app, I create the database connection in a request-scoped provider (depending on request subdomain). Authentication handled by Passport is working fine ...
Peter Bienek's user avatar
5 votes
0 answers
426 views

dusterio/lumen-passport: Pass custom data in JWT Payload

I am using lumen-passport for authentication and authorization. When I decode the JWT token I get payload as below: { "aud": "9420abb1-1470-4895-8666-a702b415cb59", "jti&...
aagjalpankaj's user avatar
  • 1,180
8 votes
2 answers
4k views

Why using passport local strategy coupled with jwt strategy

Hi I'm trying to build a NestJS API and wanna learn the best practices to do it. So I was wondering why the documentation of Nest JS https://docs.nestjs.com/security/authentication is providing an ...
Oscar Rénier's user avatar
0 votes
1 answer
708 views

Node.js - Passport JWT Auth, returning req.logIn is not a function

I use passport-jwt strategy here: const JWTstrategy = require("passport-jwt").Strategy; const ExtractJWT = require("passport-jwt").ExtractJwt; module.exports = function (passport) ...
elionntechguy's user avatar