Closed aabanaag closed 4 years ago
Figured out the issue, on my local.strategy file instead of importing Strategy from passport-local it imported from passport-jwt which is causing the issue
What did you do to fix this? I am having same issue too and I can't seem to pin point what needs to be fixed
Check "local.strategy.ts" if you have one and replace import { Strategy } from 'passport-jwt'; with import { Strategy } from 'passport-local';
Resolví el problema, en mi archivo local.strategy en lugar de importar la estrategia de passport-local que importó de passport-jwt que está causando el problema
this worked for me
Figured out the issue, on my local.strategy file instead of importing Strategy from passport-local it imported from passport-jwt which is causing the issue
this worked for me, excellent!
It worked for me as well. But I would like to know why is it this way? If anyone can explain would really help, since the entire reason for importing from passport-jwt
is that we want to implement that particular strategy
thank you for that passport-local
gooood
thanks
Figured out the issue, on my local.strategy file instead of importing Strategy from passport-local it imported from passport-jwt which is causing the issue
thanks you help me alot
Figured out the issue, on my local.strategy file instead of importing Strategy from passport-local it imported from passport-jwt which is causing the issue
Thank you !!! I could use your idea to solve my similar problem
Figured out the issue, on my local.strategy file instead of importing Strategy from passport-local it imported from passport-jwt which is causing the issue
thanks so much, this helped me
thanks boss
thank you so much this worked for me ..
Hi, I have this same issue but I tried this suggestion and it didn't work for me.
here's what my jwt strategy looks like
export class JwtStrategy extends PassportStrategy(Strategy) {
constructor(
@Inject(jwtConfig.KEY)
private jwtConfiguration: ConfigType<typeof jwtConfig>,
private authService: AuthService
) {
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
secretOrKey: jwtConfiguration.secret,
ignoreExpiration: false
});
}
async validate(payload: PayloadType) {
const userId = payload.userId
return this.authService.validateJwtUser(userId)
}
}
and here's what my error is:
TypeError: JwtStrategy requires a secret or key
at new JwtStrategy (C:\Users\Hill\Documents\logicX\numen\iluvia\fs_one\lrd_bck\node_modules\passport-jwt\lib\strategy.js:45:15)
at new MixinStrategy (C:\Users\Hill\Documents\logicX\numen\iluvia\fs_one\lrd_bck\node_modules\@nestjs\passport\dist\passport\passport.strategy.js:32:13) at GoogleStrategy (C:\Users\Hill\Documents\logicX\numen\iluvia\fs_one\lrd_bck\src\auth\google.strategy.ts:18:9)
at Injector.instantiateClass (C:\Users\Hill\Documents\logicX\numen\iluvia\fs_one\lrd_bck\node_modules\@nestjs\core\injector\injector.js:365:19)
at callback (C:\Users\Hill\Documents\logicX\numen\iluvia\fs_one\lrd_bck\node_modules\@nestjs\core\injector\injector.js:65:45)
at async Injector.resolveConstructorParams (C:\Users\Hill\Documents\logicX\numen\iluvia\fs_one\lrd_bck\node_modules\@nestjs\core\injector\injector.js:144:24)
at async Injector.loadInstance (C:\Users\Hill\Documents\logicX\numen\iluvia\fs_one\lrd_bck\node_modules\@nestjs\core\injector\injector.js:70:13)
at async Injector.loadProvider (C:\Users\Hill\Documents\logicX\numen\iluvia\fs_one\lrd_bck\node_modules\@nestjs\core\injector\injector.js:97:9)
at async C:\Users\Hill\Documents\logicX\numen\iluvia\fs_one\lrd_bck\node_modules\@nestjs\core\injector\instance-loader.js:56:13
at async Promise.all (index 7)
I get this error JwtStrategy requires a secret or key I followed the steps from NestJS on how to integrate passport for authentication.
the console looks like this
The full error:
Any ideas?