TestingAPIs is still being built. If something breaks, email support@testingapis.com.

Allow only tokens with the admin role

GEThttps://api.testingapis.com/api/auth/roles/adminSign in to see this endpoint's URL

Allow only tokens with the admin role (401 vs 403 demo).

Header: Authorization: Bearer <token> with one of the test tokens: admin-token (roles admin, user; scopes read, write, delete), user-token (role user; scopes read, write), readonly-token (no roles; scope read). Only admin-token passes.

Bearer token — admin-token

Responses

200
Token has the admin role.
401
Token missing or not one of the test tokens.
403
Valid token without the admin role.

Example

Request
curl -X GET "https://api.testingapis.com/api/auth/roles/admin" \
  -H "Authorization: Bearer admin-token" \
  -H "X-TestingApis-Key: YOUR_API_KEY"
Response200 OK
{
  "authorized": true,
  "user": "Alice Admin",
  "roles": ["admin", "user"],
  "scopes": ["read", "write", "delete"]
}

Sign in to see the details

The parameters, request and response examples and the live Try it panel for this endpoint are for signed-in members. Accounts are free and take a few seconds to create.