Roles
Available roles in a Plone site can be queried by interacting with the /@roles
endpoint on portal root (requires an authenticated user):
List Roles
To retrieve a list of all roles in the portal, call the /@roles
endpoint with a GET
request:
GET /@roles HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({ username: 'admin', password: 'admin' });
const { data } = await cli.getRoles({
token: login.data.token,
});
The server will respond with a list of all roles in the site:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"@id": "http://localhost:8080/@roles/Anonymous",
"@type": "role",
"id": "Anonymous",
"title": "Anonymous"
},
{
"@id": "http://localhost:8080/@roles/Authenticated",
"@type": "role",
"id": "Authenticated",
"title": "Authenticated"
},
{
"@id": "http://localhost:8080/@roles/Owner",
"@type": "role",
"id": "Owner",
"title": "Owner"
},
{
"@id": "http://localhost:8080/@roles/Reader",
"@type": "role",
"id": "Reader",
"title": "Reader"
},
{
"@id": "http://localhost:8080/@roles/Contributor",
"@type": "role",
"id": "Contributor",
"title": "Contributor"
},
{
"@id": "http://localhost:8080/@roles/Editor",
"@type": "role",
"id": "Editor",
"title": "Editor"
},
{
"@id": "http://localhost:8080/@roles/Reviewer",
"@type": "role",
"id": "Reviewer",
"title": "Reviewer"
},
{
"@id": "http://localhost:8080/@roles/Administrator",
"@type": "role",
"id": "Administrator",
"title": "Administrator"
}
]
The role title
is the translated role title.