Login via Twitter/X

How to configure OAuth2 login via Twitter (a.k.a. “X”)

To let your users sign in with their Twitter (X) account, follow the below steps.

  1. Log in to the Twitter Developer portal dashboard.
  2. Click on Create Project and choose a project name:
    Image
  3. Click Next and select the appropriate use case:
    Image
  4. Click Next and enter project description:
    Image
  5. After clicking Next you’ll enter the Application properties screen:
    Image
  6. Click Next once again and you’ll be presented API keys. Store them in a safe place for future reference:
    Image
  7. In app details, under User authentication settings, click Set up:
    Image
  8. Enter the following settings:
    • App permissions: Read, also enable Request email from users
      Image
    • Type of App: Web App, Automated App or Bot
      Image
    • Callback URI: https://<your-comentario-domain>/api/oauth/twitter/callback
    • Fill in other fields appropriately, then click Save:
      Image
  9. Update the secrets configuration with the above data (API Key and API Key Secret; Bearer Token is not used):
...
idp:
  twitter:
    key:    HgcP46jXCRbouchsgqJgkHPZF
    secret: Bqd7r8TaS5bcFReV7bcE2YQMt4xIrwrFSaUQ8KVJENk7JndSxV
...
  1. Restart Comentario. You should now see Twitter under Configured federated identity providers on the Static configuration page of the Administration UI.
  2. Still in the Admin UI, navigate to the desired domain properties and tick off Twitter on the Authentication tab, then click Save.
    Image

That’s it! Your users should now be able to login using the Twitter button in the Login dialog.

See also