Is there a way to create JWT like with jsonwebtoken #1468
Answered
by
jaredLunde
azimari-toure-ikbal
asked this question in
Q&A
-
Hello ! I want to know if there's a way to create jwt tokens using hono built-in functions ? I saw there's something like c.set("jwtPayload", whateverValues) but will it work ? |
Beta Was this translation helpful? Give feedback.
Answered by
jaredLunde
Sep 18, 2023
Replies: 1 comment 2 replies
-
Hono has a JWT util. As of 3.7.0, this can be used like: import * as Jwt from 'hono/jwt'
const token = await Jwt.sign(
{
sub: "SESSION_ID",
jti: "TOKEN_ID",
iat: Math.floor(Date.now() / 1000),
exp: Math.floor(Date.now() / 1000) + expiresIn,
iss: "ISSUER",
aud: "AUDIENCE",
},
env.JWT_SECRET,
); |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
azimari-toure-ikbal
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hono has a JWT util. As of 3.7.0, this can be used like: