Configuring Twitter login and rich embeds for Discourse

:bookmark: This guide explains how to set up Twitter login and rich embeds for your Discourse forum.

:person_raising_hand: Required user level: Administrator

:warning: In order for rich embeds to work properly, a Basic plan or higher for X Dev is mandatory. Rich embeds will not work with the Free X Dev plan.

X Configuration

  1. Go to the Developer Portal on X.

  2. Choose between a Free, Basic, or Pro X Dev plan and complete the developer agreement and policy requirements.

  3. After completing the agreement and policy requirements, you’ll be taken to the X dev dashboard.

Create a new project

  1. On your X Dev dashboard, click + Add Project.

  2. Complete the requested information:

    • Your project name
    • Use case. If you are using an account with a Basic or Pro plan, please select Embedding_Tweets_in_a_website.
    • Your project description (e.g., “Enable Twitter login and embeds on a Discourse forum”).
    • Select Production for the app environment. Note you may not be prompted to select the app environment.
    • Your app name
  3. You will be shown your API Key and API Key Secret. Please write these down so you can add them to your Discourse forum later.

  4. Click the App Settings button on the bottom right.

  5. Scroll down to the User Authentication Settings section and click the Set up button. Update the following fields:

    • App Permission → Read and enable Request_email_from_users
    • Type of App → Web App, Automated App or Bot
    • App info →
      • Callback URL / Redirect URL: https://yourdiscourseforum.com/auth/twitter/callback
      • Website URL: https://yourdiscourseforum.com
      • Terms of service: https://yourdiscourseforum.com/tos
      • Privacy Policy: https://yourdiscourseforum.com/privacy

  6. Click Save.

Discourse configuration

  1. Head over to your Discourse forum and enter the admin panel.

  2. Click the Settings button and choose Login to find the Twitter-related settings:

  3. Enable the enable_twitter_logins setting.

  4. Copy and paste the API Key from X into the twitter_consumer_key setting.

  5. Copy and Paste the API Key Secret from X into the twitter_consumer_secret setting.

  6. Click the green checkmark to save the changes.

Users should now be able to log into your forum using their Twitter Account.

Rich Embeds

The above steps also apply if you want to enable “rich embedding” which allows displaying tweets with their media (images video, etc). If you want rich embeds but don’t need Twitter login, simply uncheck enable twitter logins and leave the consumer key and secret intact.

:warning: Rebaking or rebuilding HTML for posts with tweets will re-fetch those tweets, counting against your monthly tweet cap.

Additional resources

Last edited by @jessii 2024-08-02T19:07:31Z

Check documentPerform check on document:
72 Likes