Skip to main content

Reading roles in an API

To do this, you must simply read the access token's payload post session verification using the getAccessTokenPayload function:

import express from "express";import { verifySession } from "supertokens-node/recipe/session/framework/express";import { SessionRequest } from "supertokens-node/framework/express";
let app = express();
app.post("/update-blog", verifySession(), async (req: SessionRequest, res) => {
    // The key "role" is used here since we used that    // while setting the access token payload     let role = req.session!.getAccessTokenPayload()["role"]
    //....});