Get access tokens

Import the function at the top of your file

import { signTokens } from "swizzle-js";

Get a JWT with getAccessToken(userId, hours?).

Optional: Pass the number of hours the token should expire after.

Returns an object with accessToken and refreshToken. accessToken should be passed in the header Authorization: Bearer<accessToken> .

const tokens = await signTokens(request.user.userId)

const accessToken = tokens.accessToken
const refreshToken = tokens.refreshToken

Last updated