Step 2: Get an access token
Now, you must exchange your client ID and client secret for an access token. The access token securely authenticates your upcoming API calls.
In this guide, we'll start by requesting an access token through the Create an access token endpoint. After that, we'll copy the access token to use in Step 3.
1. Request an access token
This guide outlines two methods to request an access token:
- Using curl: Send HTTP requests directly from your command line interface.
- Through the API reference portal: Test the endpoint directly in the API reference documentation, with options to select your preferred programming language.
Using curl
- Copy the curl example below.
curl --request POST \
--url your_environment_url/api/v2/oauth2/token \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"grant_type": "client_credentials",
"client_id": "your_client_ID",
"client_secret": "your_client_secret"
}
'
- Paste it into a text editor.
- In line 2, replace
your_environment_url
with the URL for your environment:- Production EU: https://app.360learning.com
- Production US: https://app.us.360learning.com
- In line 8, replace
your_client_ID
with your client ID. - In line 9, replace
your_client_secret
with your client secret. - Copy the code and paste it into your terminal.
- Hit Enter to execute the request.
Through the API reference portal
- Go to Create an access token.
- Under BODY PARAMS, enter:
client_id
: Your client ID.client_secret
: Your client secret.
- At the top right, select your preferred programming language.
- In the right panel under URL, click Base URL and select the appropriate URL based on your environment:
- Production EU
- Production US
- In the code snippet panel on the right, click Try it! to execute the request.
2. Copy the access token from the response
If successful, the API will return a JSON response containing your access token:
{
"token_type": "Bearer",
"access_token": "your_access_token",
"expires_in": "3600"
}
Make sure to copy the access token (your_access_token
) and store it securely, as you'll need it for the next step.
Token expiration
An access token is valid for 1 hour. After that, you'll need to request a new token to maintain access.
If you encounter any errors while making API calls, please refer to our dedicated Error handling guide for troubleshooting tips and common solutions.
Updated 6 days ago