Authentication
How to get up and running so that you can create your first Task.
Calling the Rightbrain API via OAuth 2.0 (Client Credentials Grant)
Prerequisites:
- You have created an API client from the Rightbrain dashboard and have your Client ID and Client Secret.
Steps to Call the API:
-
Obtain an Access Token:
-
To access the API, you first need to obtain an OAuth 2.0 access token. You will use your Client ID and Client Secret to request this token from the Rightbrain token endpoint.
-
Token Endpoint URL: The token URL is shown in the API client details page.
-
Request Details:
- Method:
POST
- Headers:
Content-Type
:application/x-www-form-urlencoded
- Body (Form Data):
grant_type
:client_credentials
client_id
:<YOUR_CLIENT_ID>
(Replace with your actual Client ID)client_secret
:<YOUR_CLIENT_SECRET>
(Replace with your actual Client Secret)
- Method:
-
Example Request (using
curl
): -
Example Request (Python using
requests
library): -
Successful Response: A successful token request will return a JSON response containing the
access_token
,token_type
(usually “bearer”), andexpires_in
(token expiration time in seconds).
-
-
Call the API with the Access Token:
-
Once you have the access token, you can include it in the
Authorization
header of your API requests. -
API Request Headers:
Authorization
:Bearer <YOUR_ACCESS_TOKEN>
(Replace<YOUR_ACCESS_TOKEN>
with the access token obtained in the previous step)
-
Example API Call (using
curl
to fetch a list of Tasks - example endpoint): -
Example API Call (Python using
requests
library - fetching a list of Tasks):
-
-
Handle Token Expiration:
- Access tokens have a limited lifespan (indicated by
expires_in
). Your application should handle token expiration and refresh the token when necessary. You can re-request a new access token using the same Client Credentials flow. Consider implementing token caching and refresh logic in your application.
- Access tokens have a limited lifespan (indicated by
By following these steps, you can successfully authenticate and call the Rightbrain API using OAuth 2.0 Client Credentials grant. Remember to consult the specific API endpoint documentation for request parameters, response formats, and any endpoint-specific authorization requirements.