Provider – Twitter

Twitter Sample

Table of contents

How to enable Twitter login in WordPress


  • As of July 2018, you must apply for a Twitter developer account and be approved before you may create new apps. Once approved, you will be able to create new apps from developer.twitter.com.
  • Additionally the query string is no longer supported in the Callback URL, meaning that in the URL you must leave the ? and every other parameters which come after it.

To be able to log in via Twitter you must create a Twitter app first.

  1. Navigate to https://developer.twitter.com/en/portal/projects-and-apps
  2. Log in with your Twitter credentials if you are not logged in
  3. If you don’t have a developer account yet, please apply one by filling all the required details! This is required for the next steps!
  4. Once your developer account is complete. Navigate back to https://developer.twitter.com/en/portal/projects-and-apps if you aren’t already there!
  5. Click on + New Project
  6. Name your project, and go through the basic setup. You’ll need to select your use case and give a description.
  7. Create a new app, or select an existing one, then click Complete
  8. You’ll find your API key and secret on this page. Copy and paste the API key and the API secret key to the corresponding fields at Nextend Social Login and save.
  9. Click on the App Settings button at Twitter.
  10. Find the Apps section, and the app you created a few steps ago.
  11. Click on the App settings icon. (The one that looks like a gear.)
  12. Click on the Edit button at Authentication settings.
  13. Enable Enable 3-legged OAuth.
  14. Add the following URL to the “Callback URL” field: https://yoursite.com/wp-login.php where yoursite.com is your site’s URL. ( The /wp-login.php can change to a slug of a page if you have selected one for OAuth redirect uri proxy page in Global Settings>General )
  15. Enter your site URL to Website URL
  16. If you want to get the email address as well, then don’t forget to enable the Request email address from users option. In this case you also need to fill the Terms of service and the Privacy policy fields with the corresponding URLs.
  17. Click on Save
  18. Go back to Nextend Social Login and Verify your Twitter provider.

Required Nextend Social Login settings for Twitter App

Once your Twitter app is ready you’ll need to copy and paste the API Key and API Secret key to the Twitter provider’s Settings tab. You can find the information at your Twitter app’s Settings which you can reach from the left sidebar.

Verify the settings

Once your API Key and API Secret key has been added you need to verify the setup first. This verification helps you identify possible problems with the app.

Settings

Twitter Provider Configuration

API Key

The API Key of your Twitter app. You can find it at your App → Keys and Access Tokens tab.

API Secret key

The API Secret key of your Twitter app. You can find it at your App → Keys and Access Tokens tab.

Twitter Provider Configuration

Username prefix on Register

Whenever a new user registers with their Twitter account they can get a custom prefix so you can easily identify them.

Fallback username prefix on register

Whenever a new user registers with their Twitter account and we can not generate a valid username from the first name or last name, a random username will be generated. With this option they can get a custom prefix so you can easily identify them.

Terms and conditions

This option can only be seen, if Terms and conditions is set to Show in Global Settings → Privacy tab. Here you can set custom Terms and Conditions for users who register with Twitter. For more information please read our GDPR documentation.

Sync data

By default Nextend Social Login stores the first name, last name, email, avatar url and access token if it is possible, however some additional information can also be retrieved and stored.
When an option is checked, that field will be stored in a meta key with the specified name.

Twitter Sync Data

Sync fields

It determines when the synchronization shall happen.

  • Register: whenever a new user registers with a provider, their data will be retrieved and stored.
  • Login: whenever user logs in with a provider, their data will be retrieved and stored.
  • Link: whenever user links and existing WordPress account with a provider, their data will be retrieved and stored.

Bio

Stores the user’s bio.

Language

Stores the user’s language.

Location

Stores the user’s location.

Register date

Stores the date, when the Twitter account registration happened.

Profile URL

Stores the user’s Twitter profile URL.

Screen name

Stores the user’s screen name without the @ tag.

Owned website

Stores the user’s website.

Frequently Asked Questions

1. How can I get the email address from the Twitter users?

If your app is already set up, go to the Projects & Apps Overview page, find your App and click on the App settings icon ( the one that looks like a gear). Then click on the “Edit” button at the “Authentication settings” section and switch on the “Request email address from users” setting.
Important: If you ask the email address, you also need to fill the “Terms of service” and the “Privacy policy” fields with the corresponding URLs of your site!

Common error messages returned by Twitter during verification

Callback url has been locked

Error: Unexpected response: This client application’s callback url has been locked /oauth/request_token

The problem is that the entered Callback URL field is not correct for your app. Check the 14th step of the App setup to fix the problem.

oauth_callback value ‘oob’

Error: Unexpected response: Desktop applications only support the oauth_callback value ‘oob’ /oauth/request_token

The problem is that the entered Callback URL field is not correct for your app. Check the 14th step of the App setup to fix the problem.

Not a valid callback URL format

Error The client application failed validation: Not a valid callback URL format.

The problem is that the entered Callback URL field is not correct for your app or it may contain whitespace character. Check the 14th step of the App setup to fix the problem.

Could not authenticate you

Error: Could not authenticate you

The entered API Key is not correct. Maybe the app with the entered ID was deleted. Go to the Twitter provider → Settings and make sure that an existing App’s API Key and API Secret key was entered.