Connect Apps to Twitter
The Twitter social connection allows users to log in to your application using their Twitter profile.
By default, Auth0 automatically syncs user profile data with each user login, thereby ensuring that changes made in the connection source are automatically updated in Auth0. Optionally, you can disable user profile data synchronization to allow for updating profile attributes from your application.
Before you begin, apply for a Twitter Developer account.
To connect your app to Twitter, you will:
Set up app in Twitter
Create a project and add a new app in the Twitter Developer portal. During this process, Twitter will generate an API Key and API Secret Key for your application; make note of these.
While setting up your app, use the following values:
|Field||Value to Provide|
|Enable 3rd party authentication||Toggle the switch to enable.|
|App permissions||Select the option that fitst your requirements. By default, your application will be granted Read Only permission.|
Find your Auth0 domain name
If your Auth0 domain name is not shown above and you are not using our custom domains feature, your domain name is your tenant name, your regional subdomain (unless your tenant is in the US region and was created before June 2020), plus
.auth0.com. For example, if your tenant name were
exampleco-enterprises, your Auth0 domain name would be
exampleco-enterprises.us.auth0.com and your callback URL would be
https://exampleco-enterprises.us.auth0.com/login/callback. (If your tenant is in the US and was created before June 2020, then your domain name would be
If you are using custom domains, your redirect URI will have the following format:
https://<YOUR CUSTOM DOMAIN>/login/callback.
Create and enable connection in Auth0
Set up the Twitter social connection in Auth0. Make sure you have the generated API Key and API Secret Key.
You're ready to test your connection.
Access Twitter API
Once a user successfully authenticates, Twitter will include an Access Token in the user profile it returns to Auth0. You can use this token to call Twitter's API.
To get the Twitter Access Token, you must retrieve the full user's profile using the Auth0 Management API and extract the Access Token from the response. For detailed steps, see Call an Identity Provider's API.
Using the token, you can call Twitter's API following Twitter's documentation.
If you are seeing errors, refer to the following troubleshooting steps.
User's email address is missing from retrieved user profile
Auth0 provides a rule template to get email addresses from Twitter. To use it, create a new rule with the Get Email Address from Twitter template under the Enrich Profile section.
If you are using Auth0 developer keys, this functionality will not work; you will need to use your Twitter API Key and API Secret Key.
You must also explicitly request permission to retrieve user email addresses for your Twitter app:
- Log in to Twitter Developer Project and App Management.
- Choose your project, and then your app settings.
- Click Edit next to Authentication settings, then toggle the switch to enable Request email address from users.