Bird
0
0

Identify the error in this NestJS refresh token validation snippet:

medium📝 Debug Q6 of 15
NestJS - Authentication
Identify the error in this NestJS refresh token validation snippet:
const payload = this.jwtService.verify(refreshToken, { secret: process.env.ACCESS_TOKEN_SECRET });
AMissing async keyword in method
BNo error; code is correct
CIncorrect method name; should be decode()
DUsing ACCESS_TOKEN_SECRET instead of REFRESH_TOKEN_SECRET
Step-by-Step Solution
Solution:
  1. Step 1: Check secret key usage for refresh token

    Refresh tokens should be verified with REFRESH_TOKEN_SECRET, not ACCESS_TOKEN_SECRET.
  2. Step 2: Confirm method correctness

    verify() is correct method; async keyword is unrelated here.
  3. Final Answer:

    Using ACCESS_TOKEN_SECRET instead of REFRESH_TOKEN_SECRET -> Option D
  4. Quick Check:

    Correct secret key for refresh token = REFRESH_TOKEN_SECRET [OK]
Quick Trick: Use correct secret for refresh token verification [OK]
Common Mistakes:
  • Mixing access and refresh token secrets
  • Thinking decode() verifies signature
  • Assuming async needed for verify()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes