Configure Twitter login and rich embeds for Discourse

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

Twitter configuration

Go to https://developer.twitter.com/en/portal/projects-and-apps

Create the Twitter application

Click + Add Project

Complete the 4 steps.

  1. Complete the three next steps:

    1. Write down the API Key[1] and the API Key Secret[2]. You’ll need them later.

Configure the app settings

Click App Settings on the bottom right.

Click Set Up in User authentication settings:

Fill in the form. Change the URLs in App Info accordingly to your forum’s URLs.

Click Save.

Discourse’s configuration

In your admin panel, go to Login and find the Twitter-related settings:

  • Check enable twitter logins

  • Put your API Key in the twitter consumer key field

  • Put your API Key Secret twitter consumer secret field

You should now be able to log in with your 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.


Rebaking Posts / Rebuild HTML

:warning: It’s important to know that rebaking or using the rebuild HTML button on posts that contain tweets will re-pull the tweet(s) and count them towards your monthly tweet cap usage.


  1. Also know as twitter consumer key ↩︎

  2. Also known as twitter consumer secret ↩︎

72 Likes

Note that the “Callback URL” field is now mandatory. If you omitted it in your setup, Twitter login will fail with a 403 unauthorized error.

Also note that if you have any extra spaces at the beginning or end of your callback urls, auth will fail. You can find other discussions about this change on the Twitter Community.

13 Likes

Just noticed we were getting the same error on our site with Twitter auth. I noticed Twitter has a new process for authorizing developer apps, so we are going through the approval process. Not sure if it is related, or if this problem has just been in place for a long time now.

1 Like

I setup my callback URL like this on Twitter, but still getting the same error.
https://www.helloforos.com/auth/twitter

Does this look like the right format? What do you guys use?

I’m going to try it again tomorrow in case there’s some caching issue with Twitter

Anyone else have success with Twitter login?

@charleswalter That callback url is wrong. It should be:

7 Likes

that did the trick. Thx for calling that out.

I do recommend that those who haven’t applied on developer.twitter.com for their Twitter app, to do so.

For the near future, you can continue to manage existing apps here on apps.twitter.com. However, we will soon retire this site and consolidate all developer tools, API access, and app management within the developer portal at developer.twitter.com. You will be able to access and manage existing apps through that portal when we retire this site.

5 Likes

March 2020

Guide completely rewritten because Twitter has changed the whole process … another time :sweat_smile:

16 Likes

Twitter, Doesn’t seem to work

Cannot add Create an app

1 Like

It works for me

image

and looking at https://api.twitterstat.us/ the Developer Portal is ok.

You are probably using some extension that blocks social media, tracking or something similar. Try logging in from an anonymous window with all extensions disabled

4 Likes

The guide has been updated

7 Likes

I hope this is the right place to ask this question. I see from https://try.discourse.org/ that registration by Twitter leads to the following message:

This application will be able to:

See Tweets from your timeline (including protected Tweets) as well as your Lists and collections.
See your Twitter profile information and account settings.
See accounts you follow, mute, and block.
See your email address.

Is it possible to set it up where it sees the minimum amount of information necessary - name and email address I think?

1 Like

This is already the minimum information required by Twitter.

As you can see from the guide, the only thing we require from Twitter is the user email that Discourse needs to create the user account. Everything else is the basic settings decided by Twitter selecting “Read only” in the App Permission section.

6 Likes

Hi I’m trying to embed a reply to a tweet.

The embed should look like this.

I just get the reply. Not the original Tweet too.
Is this just the way it works on Discourse or am I doing something wrong?

2 Likes

I don’t use Twitter, but I assume the reply link is different from the original tweet’s link. Therefore, you are only linking to the reply. Does linking to the original tweet also include the first reply or just the original tweet?

1 Like

Hi Jimpas,

No the idea is that if you embed the reply you can choose to have the original tweet above it as in the pic. So the reply has context.
I quite like the styling too.

I’m just getting the reply.
A workaround is two embeds.

1 Like

That is indeed a work-around. But how can you choose to have the original tweet above a reply? So how would one “choose”? I do see at times someone posts on another website that the original tweet has the first reply to it. :thinking:

I am noticing the same registration issue as well. When I try using a test account, and Twitter even states at register that email is being accessed, the email account is not prefilled into the account registration form after completing the authentication handshake with Twitter, and it is also showing “user_1” for the prefilled username. Rich embeds are not working as well.

1 Like

Not panic and wait patiently. The Discourse team reads every post very carefully, so I am sure they are already on top of this. :slight_smile:

2 Likes

@Hifihedgehog and @dnfoz this has been assigned out, we will review it shortly. Does anyone else have issues with setting this up and logging in?

4 Likes

Any update ?? I have the same issue

1 Like