The Topcoder Review API supports machine-to-machine (M2M) authentication using Auth0 for service-to-service integrations. This guide explains how to use M2M tokens with the API.
Machine-to-Machine tokens are designed for service-to-service authentication where a human user is not directly involved. Instead of using user roles for authorization, M2M tokens use scopes, which are permissions attached to the token.
M2M tokens from Auth0 contain the following important claims:
iss(issuer): The Auth0 domain that issued the tokensub(subject): The client ID of the applicationaud(audience): The API identifier (audience)exp(expiration time): When the token expiresiat(issued at time): When the token was issuedscope: Space-separated list of authorized scopes
The Topcoder Review API supports the following scopes:
read:groups- Do read action of groupswrite:groups- Do write action of groupsall:groups- All groups-related operations
To get an M2M token, you need to have a client registered in Auth0 with the appropriate permissions.
curl --request POST \
--url https://topcoder-dev.auth0.com/oauth/token \
--header 'content-type: application/json' \
--data '{
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"audience": "https://m2m.topcoder-dev.com/",
"grant_type": "client_credentials"
}'{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6...",
"scope": "read:appeal create:review all:scorecard",
"expires_in": 86400,
"token_type": "Bearer"
}Include the token in your API requests in the Authorization header:
Authorization: Bearer YOUR_ACCESS_TOKEN
When a request is made to the API, the token's scopes are validated against the required scopes for the endpoint. If the token has at least one of the required scopes, access is granted.
Scopes that start with "all:" automatically grant access to all the specific operations in that category.
For example, all:groups includes read:groups, write:groups, etc.
For testing locally, you can use the following predefined test tokens:
m2m-token-all- Has all available scopesm2m-token-groups- Has all groups scopes
Example usage with curl:
curl -X GET http://localhost:3000/v6/groups \
-H "Authorization: Bearer m2m-token-review"If you receive a 403 Forbidden response, check that:
- Your token is valid and not expired
- The token has the required scope for the endpoint
- You're using the correct audience and issuer