Reference
Twitter (X)
Set up Twitter (X) OAuth for reading and posting tweets
Overview
Section titled “Overview”Connect your users to Twitter (X) for reading tweets, posting content, managing follows, and accessing user data.
| Property | Value |
|---|---|
| Provider ID | twitter |
| Category | Social |
| PKCE | Required |
| Token refresh | Automatic |
| Redirect URI | Shown in Developer Portal |
Step 1: Create a Twitter OAuth App
Section titled “Step 1: Create a Twitter OAuth App”Go to the Twitter Developer Portal
Navigate to developer.x.com/en/portal/dashboard and sign in.
Create a new project and app
Click Add App (or create a new Project first), enter the app name, and select the use case.
Configure OAuth 2.0
In app settings, under User authentication settings, enable OAuth 2.0. Set the Type of App to Web App. Add the Alter callback URL from the Developer Portal to the Callback URI field.
Get credentials
Copy the Client ID and Client Secret from the Keys and tokens tab.
Step 2: Add to Alter Vault
Section titled “Step 2: Add to Alter Vault”Open the Developer Portal
Go to portal.alterauth.com and navigate to the application.
Add Twitter provider
Go to OAuth Providers > Add Provider > Twitter (X).
Enter credentials
- Client ID: Paste your Twitter Client ID
- Client Secret: Paste your Twitter Client Secret
Select scopes
Choose the scopes the application needs.
Save
Click Save. The provider is now active.
Available Scopes
Section titled “Available Scopes”| Scope | Description |
|---|---|
tweet.read | All the Tweets you can view, including Tweets from protected accounts |
tweet.write | Tweet and Retweet on behalf of the user |
tweet.moderate.write | Hide and unhide replies to the user’s Tweets |
users.read | Any account you can view, including protected accounts |
users.email | Read the authenticated user’s email address |
follows.read | View who a user follows and their followers |
follows.write | Follow and unfollow people on behalf of the user |
offline.access | Stay connected until access is revoked (refresh tokens) |
space.read | View Twitter Spaces the user can access |
mute.read | View accounts the user has muted |
mute.write | Mute and unmute accounts on behalf of the user |
like.read | View tweets the user has liked |
like.write | Like and unlike tweets on behalf of the user |
list.read | View lists, members, and followers for lists the user created or joined |
list.write | Create and manage lists on behalf of the user |
block.read | View accounts the user has blocked |
block.write | Block and unblock accounts on behalf of the user |
bookmark.read | View bookmarked tweets |
bookmark.write | Bookmark and remove bookmarks on behalf of the user |
dm.read | View Direct Messages, including from protected accounts |
dm.write | Send and manage Direct Messages on behalf of the user |
media.write | Upload media for posts and Direct Messages |
- Twitter OAuth 2.0 requires PKCE. Alter Vault handles this automatically.
- Always include
offline.accessto receive a refresh token. - See the Twitter OAuth 2.0 documentation for more details.
Policy-cataloged operations
Section titled “Policy-cataloged operations”Alter policy rules can target these attested operations and families for operation-level and parameter-aware controls.
| Operation ID | Families | Method | Provider path |
|---|---|---|---|
createPosts | send | POST | /2/tweets |
deletePosts | delete | DELETE | /2/tweets/{id} |
getPostsById | read | GET | /2/tweets/{id} |
getPostsByIds | read | GET | /2/tweets |
searchPostsRecent | read | GET | /2/tweets/search/recent |
getUsersMe | read | GET | /2/users/me |
getUsersById | read | GET | /2/users/{id} |
getUsersByUsername | read | GET | /2/users/by/username/{username} |
getUsersPosts | read | GET | /2/users/{id}/tweets |
getUsersMentions | read | GET | /2/users/{id}/mentions |
getUsersFollowers | read | GET | /2/users/{id}/followers |
getUsersFollowing | read | GET | /2/users/{id}/following |
likePost | write | POST | /2/users/{id}/likes |
unlikePost | write | DELETE | /2/users/{id}/likes/{tweet_id} |
repostPost | write | POST | /2/users/{id}/retweets |
unrepostPost | write | DELETE | /2/users/{id}/retweets/{source_tweet_id} |
followUser | write | POST | /2/users/{id}/following |
unfollowUser | write | DELETE | /2/users/{source_user_id}/following/{target_user_id} |
muteUser | write | POST | /2/users/{id}/muting |
unmuteUser | write | DELETE | /2/users/{source_user_id}/muting/{target_user_id} |
createDirectMessagesConversation | send | POST | /2/dm_conversations |
createDirectMessagesByConversationId | send | POST | /2/dm_conversations/{dm_conversation_id}/messages |
createDirectMessagesByParticipantId | send | POST | /2/dm_conversations/with/{participant_id}/messages |
getDirectMessagesEventsByConversationId | read | GET | /2/dm_conversations/{id}/dm_events |