Request an access token
const url = 'https://app.commitly.com/api/auth/token/';const options = { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: new URLSearchParams({ grant_type: 'client_credentials', client_id: 'YOUR_CLIENT_ID', client_secret: 'YOUR_CLIENT_SECRET' })};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://app.commitly.com/api/auth/token/ \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data grant_type=client_credentials \ --data client_id=YOUR_CLIENT_ID \ --data client_secret=YOUR_CLIENT_SECRETExchanges the Client ID and Client Secret for an access token (OAuth 2.0 client
credentials grant). Send the credentials in the request body as
application/x-www-form-urlencoded, multipart/form-data or
application/json. HTTP Basic authentication of the client is not supported.
The access token is valid for 5 minutes. When it has expired, request a new token with the client credentials.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Client ID from Add-ons > COMMITLY Public API.
Client Secret from Add-ons > COMMITLY Public API.
Example
grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRETobject
Client ID from Add-ons > COMMITLY Public API.
Client Secret from Add-ons > COMMITLY Public API.
object
Client ID from Add-ons > COMMITLY Public API.
Client Secret from Add-ons > COMMITLY Public API.
Example
{ "grant_type": "client_credentials", "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET"}Responses
Section titled “Responses”Access token issued.
object
Send as Authorization: Bearer <access_token>.
Always bearer (lowercase).
Refresh token.
Lifetime of the access token in seconds (300, i.e. 5 minutes).
Lifetime of the refresh token in seconds (1209600, i.e. 14 days).
Space-separated scopes of the token, or all.
Example
{ "access_token": "YOUR_ACCESS_TOKEN", "token_type": "bearer", "refresh_token": "YOUR_REFRESH_TOKEN", "expires_in": 300, "refresh_expires_in": 1209600, "scope": "all"}Invalid or missing client credentials. The message is localized (see
Accept-Language).
object
Error messages. Localized (see Accept-Language).
Example
{ "non_field_errors": [ "Invalid client credentials." ]}
