OAuth Token API
Access Tokens can be generated by calling the Token API endpoint and passing Client ID and Client Secret of an OAuth app. This API is part of OAuth apps and is currently in public beta.
POST https://oauth.twilio.com/v2/token
Encoding type:application/x-www-form-urlencoded
| Parameter | Type | Required | Description | 
|---|---|---|---|
| client_id | string | yes | The unique identifier of an OAuth app | 
| client_secret | string | yes | The confidential secret associated with the client ID | 
| grant_type | string | yes | Specify the OAuth grant type. Right now we only support Client Credentials so this must be set to client_credentials | 
1curl --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": null7}
Response Fields
| Parameter | Type | Description | 
|---|---|---|
| access_token | string | The Access Token issued by the authorization server | 
| token_type | string | The type of token (typically Bearer) | 
| expires_in | integer | The token lifetime in seconds | 
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
1curl --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:
- Java SDK version 10.6.0 and above:
- README
- Public OAuth example.
- C# SDK version 7.6.0 and above:
- Node SDK version 5.4.0 and above:
- Python SDK version 9.4.1 and above:
- Ruby SDK version 7.4.0 and above:
- PHP SDK version 8.5.0 and above:
- Go SDK version 1.25.1 and above: