Skip to content

Reference

Twitter (X)

Set up Twitter (X) OAuth for reading and posting tweets

Connect your users to Twitter (X) for reading tweets, posting content, managing follows, and accessing user data.

PropertyValue
Provider IDtwitter
CategorySocial
PKCERequired
Token refreshAutomatic
Redirect URIShown in Developer Portal

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.

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.

ScopeDescription
tweet.readAll the Tweets you can view, including Tweets from protected accounts
tweet.writeTweet and Retweet on behalf of the user
tweet.moderate.writeHide and unhide replies to the user’s Tweets
users.readAny account you can view, including protected accounts
users.emailRead the authenticated user’s email address
follows.readView who a user follows and their followers
follows.writeFollow and unfollow people on behalf of the user
offline.accessStay connected until access is revoked (refresh tokens)
space.readView Twitter Spaces the user can access
mute.readView accounts the user has muted
mute.writeMute and unmute accounts on behalf of the user
like.readView tweets the user has liked
like.writeLike and unlike tweets on behalf of the user
list.readView lists, members, and followers for lists the user created or joined
list.writeCreate and manage lists on behalf of the user
block.readView accounts the user has blocked
block.writeBlock and unblock accounts on behalf of the user
bookmark.readView bookmarked tweets
bookmark.writeBookmark and remove bookmarks on behalf of the user
dm.readView Direct Messages, including from protected accounts
dm.writeSend and manage Direct Messages on behalf of the user
media.writeUpload media for posts and Direct Messages
  • Twitter OAuth 2.0 requires PKCE. Alter Vault handles this automatically.
  • Always include offline.access to receive a refresh token.
  • See the Twitter OAuth 2.0 documentation for more details.

Alter policy rules can target these attested operations and families for operation-level and parameter-aware controls.

Operation IDFamiliesMethodProvider path
createPostssendPOST/2/tweets
deletePostsdeleteDELETE/2/tweets/{id}
getPostsByIdreadGET/2/tweets/{id}
getPostsByIdsreadGET/2/tweets
searchPostsRecentreadGET/2/tweets/search/recent
getUsersMereadGET/2/users/me
getUsersByIdreadGET/2/users/{id}
getUsersByUsernamereadGET/2/users/by/username/{username}
getUsersPostsreadGET/2/users/{id}/tweets
getUsersMentionsreadGET/2/users/{id}/mentions
getUsersFollowersreadGET/2/users/{id}/followers
getUsersFollowingreadGET/2/users/{id}/following
likePostwritePOST/2/users/{id}/likes
unlikePostwriteDELETE/2/users/{id}/likes/{tweet_id}
repostPostwritePOST/2/users/{id}/retweets
unrepostPostwriteDELETE/2/users/{id}/retweets/{source_tweet_id}
followUserwritePOST/2/users/{id}/following
unfollowUserwriteDELETE/2/users/{source_user_id}/following/{target_user_id}
muteUserwritePOST/2/users/{id}/muting
unmuteUserwriteDELETE/2/users/{source_user_id}/muting/{target_user_id}
createDirectMessagesConversationsendPOST/2/dm_conversations
createDirectMessagesByConversationIdsendPOST/2/dm_conversations/{dm_conversation_id}/messages
createDirectMessagesByParticipantIdsendPOST/2/dm_conversations/with/{participant_id}/messages
getDirectMessagesEventsByConversationIdreadGET/2/dm_conversations/{id}/dm_events

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.