vladwulf / nestjs-jwts

NestJs jwt tutorial using access and refresh tokens
376 stars 105 forks source link

Error: Unknown authentication strategy "jwt-refresh" #2

Open SergioJuniorCE opened 2 years ago

SergioJuniorCE commented 2 years ago

I was following the tutorial as close as possible, I even have the exact same code

import { AuthGuard } from '@nestjs/passport';

export class RefreshTokenGuard extends AuthGuard('jwt-refresh') {
  constructor() {
    super();
  }
}

this is the error that I get

[Nest] 11492  - 21/12/2021, 11:45:25 pm   ERROR [ExceptionsHandler] Unknown authentication strategy "jwt-refresh"
Error: Unknown authentication strategy "jwt-refresh"
    at attempt (D:\dev\alejandria\jwt-test\node_modules\passport\lib\middleware\authenticate.js:193:39)
    at authenticate (D:\dev\alejandria\jwt-test\node_modules\passport\lib\middleware\authenticate.js:370:7)
    at D:\dev\alejandria\jwt-test\node_modules\@nestjs\passport\dist\auth.guard.js:91:3
    at new Promise (<anonymous>)
    at D:\dev\alejandria\jwt-test\node_modules\@nestjs\passport\dist\auth.guard.js:83:83
    at RefreshTokenGuard.<anonymous> (D:\dev\alejandria\jwt-test\node_modules\@nestjs\passport\dist\auth.guard.js:49:36)
    at Generator.next (<anonymous>)
    at fulfilled (D:\dev\alejandria\jwt-test\node_modules\@nestjs\passport\dist\auth.guard.js:17:58)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
vladwulf commented 2 years ago

Have you provided the jwt-refresh strategy in the auth module providers array?

dtrokhlib commented 2 years ago

@vladwulf thanks, that is exact problem I have run into, everything works well with added strategy to providers )

lilianQ-Q commented 1 year ago

What about closing this issue ?