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 getJWTPayload function:

let Session = require("supertokens-node/recipe/session");
app.post("/update-blog", Session.verifySession(), (req, res) => {
    // The key "role" is used here since we used that    // while setting the JWT payload     let role = req.session.getJWTPayload()["role"] 
    //....});