Set up OAuth for SCIM
Before you can use the SCIM API, you must create an OAuth application and get an access token. This page explains how to create an OAuth application, authorize it, and generate an access token for SCIM API requests.
Info
Many identity providers perform authorization on your behalf. See Okta SCIM integration or the user documentation for your IdP for more information.
You must be an Organization Owner or Organization Admin to create and authorize OAuth applications.
Warning
To avoid service disruptions when users are deactivated or removed from your organization, create a dedicated user account (sometimes called a service account) with email-based login credentials that a group of people can access for this setup.
- Sign in to the Twilio Console.
- Click Admin in the top-right corner to open the Admin Center.
- Go to Applications > OAuth apps.
- Click Create OAuth app.
- Select Authorization code as the grant type.
- Enter the application details:
- For Application name, enter a name for your OAuth app.
- For Company Name, enter your company name.
- For Redirect URL enter an identity provider URL where Twilio should redirect the user after they authorize your app. For example,
https://example.com/token. - For Scopes and Permissions, select all
managed-usersscopes.
- Click Save.
After you save your configuration, Twilio generates the Client ID, Client Secret, and Authorization URL. Copy these values and store the Client Secret securely. Twilio shows the Client Secret only once.
You can exchange the authorization code for access and refresh tokens.
1curl --location 'https://oauth.twilio.com/v2/token' \2--header 'Content-Type: application/x-www-form-urlencoded' \3--data-urlencode 'client_id=CLIENT_ID' \4--data-urlencode 'client_secret=CLIENT_SECRET' \5--data-urlencode 'grant_type=authorization_code' \6--data-urlencode 'code=AUTHORIZATION_CODE' \7--data-urlencode 'redirect_uri=REDIRECT_URL'
Replace the following placeholders in the above cURL request:
- Replace
CLIENT_IDwith your OAuth application's Client ID. - Replace
CLIENT_SECRETwith your OAuth application's Client Secret. - Replace
AUTHORIZATION_CODEwith the authorization code from the previous step. - Replace
REDIRECT_URLwith your configured Redirect URL.
1{2"access_token": "ACCESS_TOKEN",3"id_token": null,4"token_type": "Bearer",5"expires_in": 3600,6"refresh_token": "REFRESH_TOKEN"7}
This response includes the following values:
ACCESS_TOKEN: the access token to authenticate SCIM API requests.REFRESH_TOKEN: the refresh token to obtain new access tokens.
The access token is a JSON Web Token (JWT) that expires after one hour. Use the refresh token to obtain new access tokens without reauthorizing.
Include the access token in the Authorization header for SCIM API requests:
1curl --location 'https://iam.twilio.com/scim/v2/Users' \2--header 'Authorization: Bearer ACCESS_TOKEN'
Replace ACCESS_TOKEN with your access token.
After setting up OAuth, you can explore the following resources:
- SCIM API reference: View the complete API reference for user management endpoints.
- Okta integration: Configure SCIM provisioning with Okta as your identity provider.