List all roles
You can fetch all the roles that you have created
tip
You can also view all the roles from the user management dashboard. To know more about how to manage your user roles and permissions from user management dashboard see this page
- NodeJS
- GoLang
- Python
- cURL
Important
For other backend frameworks, you can follow our guide on how to spin up a separate server configured with the SuperTokens backend SDK to authenticate requests and issue session tokens.
import UserRoles from "supertokens-node/recipe/userroles";
async function getAllRoles() {
const roles: string[] = (await UserRoles.getAllRoles()).roles;
}
import (
"github.com/supertokens/supertokens-golang/recipe/userroles"
)
func getAllRoles() {
response, err := userroles.GetAllRoles(nil)
if err != nil {
// TODO: Handle error
return
}
_ = response.OK.Roles
}
- Asyncio
- Syncio
from supertokens_python.recipe.userroles.asyncio import get_all_roles
async def create_role():
_ = (await get_all_roles()).roles
from supertokens_python.recipe.userroles.syncio import get_all_roles
def create_role():
_ = get_all_roles().roles
- Single app setup
- Multi app setup
curl --location --request GET '/recipe/roles' \
--header 'api-key: '
curl --location --request GET '/recipe/roles' \
--header 'api-key: '