In node js, I implemented a JWT token. I'm able to create a jwt token. Now I'd like to see when it will expire or become invalid. According to the documentation, it will expire after 120 milliseconds. However, my token will not expire. Why does it always decode the token?
This is how I make the token.
app.get("/saveData", async (req, res) => {
try {
const token = await userService.create({
userId: "abcp",
password: "hello",
appsAccess: ["yes", "test"]
});
res.send(token);
} catch (error) {
console.log(error);
}
});
and verify the token like this
app.get("/verify-token", async (req, res) => {
let tokenStatus = await userService.verifyAccessToken(
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXJJZCI6ImFiY3AiLCJhcHBzQWNjZXNzIjpbInllcyIsInRlc3QiXSwiX2lkIjoiNWQ3Yzk4MTYzZmQ1NGIwOGUwMjYzNjg0IiwiX192IjowfSwiaWF0IjoxNTY4NDQ2NDg2LCJpc3MiOiJqamoiLCJzdWIiOiJhYmNwIn0.1fqzYJ1p9jSIiNjbA7MwEsU4EsMmmpxF34TU1ZjonSA"
);
res.send(tokenStatus);
});
here is my code
verifyAccessToken(token) { return jwt.verify(token, "jhjhhj"); }
I want if i generate the token it will expire after 10min or 30min