Skip to content
Discussion options

You must be logged in to vote

In case anyone else is running into this, here's how I did it for JWT:

  import jwt from "next-auth/jwt";
  import { set } from "next-auth/dist/server/lib/cookie";

  // ideally there would be a way to get the payload from a next-auth primitive
  const jwtPayload = {
    name: <user name>,
    email: <user email>,
    picture: <user picture>,
    sub: <user id>,
    ... // any additional fields you include in your jwt callback
  };
  const newEncodedJwt = await jwt.encode({
    secret: <your secret>,
    token: jwtPayload,
  });

  const cookieExpires = new Date();
  const maxAge = 30 * 24 * 60 * 60; // should be the same value you use in your NextApiHandler
  cookieExpires.setTime(cookie…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by andrew-spg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant