Authenticate users with Twitter/X via createTwitterProvider. Covers OAuth 2.0 PKCE, Developer Portal configuration, and users.read and tweet.read scopes.
Setup
1
Get credentials
Go to the Twitter Developer Portal and create a project and app. Under User authentication settings, enable OAuth 2.0 and set the redirect URI to:
Default scopes: users.read, tweet.read. Scopes you pass are added on top of the defaults.
Scope
What it unlocks
users.read
Read the user’s profile
tweet.read
Read tweets
offline.access
Refresh token support
Twitter does not return an email address through the standard OAuth 2.0 flow. The provider reports a synthetic non-deliverable address (username@twitter.invalid) as the email, and the oauth() plugin stores it on the user record because it matches users by email. Do not treat it as a real email.