Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page

Generate OAuth apps Access Token


Access Tokens can be generated by calling the Token API endpoint and passing Client ID and Client Secret of an OAuth app.


OAuth Token API

oauth-token-api page anchor

POST https://oauth.twilio.com/v2/token

Encoding type:application/x-www-form-urlencoded

Request body parameters

request-body-parameters page anchor
ParameterTypeRequiredDescription
client_idstringyesThe unique identifier of an OAuth app
client_secretstringyesThe confidential secret associated with the client ID
grant_typestringyesMust be set to client_credentials
1
curl --location 'https://oauth.twilio.com/v2/token' \
2
--header 'Content-Type: application/x-www-form-urlencoded' \
3
--data-urlencode 'client_id={ClientID}' \
4
--data-urlencode 'client_secret={ClientSecret}' \
5
--data-urlencode 'grant_type=client_credentials'

Status: 200 OK

Body(JSON):

1
{
2
"access_token": "{AccessToken}",
3
"id_token": null,
4
"token_type": "Bearer",
5
"expires_in": 3600,
6
"refresh_token": null
7
}

Response Fields

ParameterTypeDescription
access_tokenstringThe Access Token issued by the authorization server
token_typestringThe type of token (typically Bearer)
expires_inintegerThe token lifetime in seconds

Examples for API resouce calls

examples-for-api-resouce-calls page anchor

Use the access_token generated as response from Token API endpoint as bearer token in the Authorization header for Twilio API requests.

cURL example to GET list of Messages of an account

1
curl --location 'https://api.twilio.com/2010-04-01/Accounts/<AccountSID>/Messages.json' \
2
--header 'Authorization: Bearer {AccessToken}'

OAuth support for Twilio APIs is available in all server-side SDKs. Here are details of the versions and examples: