Creating a Twilio OAuth 2.0 app (authorization code)
This guide is part of the Publicus connection catalog. Once you have the credentials, connect the service and Publicus stores them for you.
Distilled from Twilio’s own documentation: Organization-level OAuth apps, OAuth apps overview, OAuth Token API, and OAuth apps FAQs. Retrieved 2026-07-03.
The authorization code grant is for accessing Twilio APIs on behalf of a specific user who signs in and approves access. Organization-level OAuth apps support both client credentials and authorization code; account-level OAuth apps support only client credentials. OAuth for Twilio APIs is currently US1-region only.
- Log in to the Twilio Console and go to Settings > Organization settings > Organization API access. Click Create OAuth application.
- Select grant type Authorization code.
- Enter the application details: name, description, company name, images, homepage URL, terms-of-service URL, and the Redirect URL (must exactly match the
redirect_uriyou send later). - On the Scopes & permissions page, select the permissions the app needs.
- On the Copy secret page, copy the Client ID, Client Secret, and Authorization URL and store them securely. Confirm with Got it! > Finish.
Authorize the app to obtain a code. Build the authorization URL:
https://oauth.twilio.com/v2/authorize?client_id=CLIENT_ID&response_type=code&scope=offline_access&redirect_uri=REDIRECT_URL&state=STATEOpen it in a browser and Approve access. The authorization page does not support SSO login — use an organization admin user whose SSO is deactivated. Twilio redirects to REDIRECT_URL?code=AUTHORIZATION_CODE&state=STATE. The code expires after five minutes, so exchange it immediately:
curl --location 'https://oauth.twilio.com/v2/token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'client_id={CLIENT_ID}' \ --data-urlencode 'client_secret={CLIENT_SECRET}' \ --data-urlencode 'grant_type=authorization_code' \ --data-urlencode 'code=AUTHORIZATION_CODE' \ --data-urlencode 'redirect_uri={REDIRECT_URL}'The success response includes an access_token (a JWT, expires_in default 3600), token_type: "Bearer", and a refresh_token. Refresh with grant_type=refresh_token at the same endpoint. Call the API with Authorization: Bearer {AccessToken}.
Operational notes:
- The
offline_accessscope is what yields therefresh_token. - Product permissions are configured on the OAuth app in the Console (see Twilio’s Permission-to-API mapping), not requested per authorization.
- The authorization-code grant is only available to organization-level OAuth apps, and its tokens address Twilio’s organization-level IAM APIs at
https://iam.twilio.com— SCIM users (/scim/v2/Users),/v2/Organizations/RoleAssignments, and/v2/Organizations/Roles(see Organization-level OAuth apps). It does not authenticate the Communications APIs atapi.twilio.com(Messages, Calls, …); for those use the client-credentials grant, an API key, or the Account SID/Auth Token.
Connect it to Publicus
Section titled “Connect it to Publicus”Open Connections under Credentials, choose Twilio, and pick Twilio OAuth 2.0 (authorization code). Publicus asks for exactly the fields listed above and keeps them in your workspace’s secret storage.
See also: Twilio in the catalog.
This guide is maintained by Publicus and published under CC BY 4.0.