Configuring Twitter login (and rich embeds) for Discourse

  1. Go to developer.twitter.com/apps and sign in with a Twitter account. If you have not yet created a Twitter developer account, you will be asked to create one.

  2. Click the Create an app button and apply for a developer account.

    image

    image

  3. Fill in all mandatory fields, read and accept the Developer Agreement


    At this point you will be you will be asked to name your app. From your Dashboard you will see your the newly created app

  4. Open the app settings
    firefox_1Lk9IiP0IF

    • The App Permissions should be set to Read Only

    • Enable the Authentication Settings clicking on the :pencil2: Edit button.

  5. In the Authentication Setting tab be sure to:

    • Activate the setting Enable 3rd party authentication

    • Activate the setting Request email address for users

    • Enter the Callback URLs of your site, e.g. https://forum.example.com/auth/twitter/callback (replacing the domain with your site’s actual domain name. The preferred protocol is in HTTPS. All the sites we host are already configured to use the HTTPS protocol)

    • Enter the Website URL, e.g. https://forum.example.com, (replacing the domain with your site’s actual domain name. The preferred protocol is in HTTPS.)

    • Enter the URLs for your tos and policy stuff. If you have an organization, also fill in the fields related to it

    • Save

  6. Click on the Keys and tokens tab and then click on :eye: View Keys.

    • Enter your Discourse site settings and search for “twitter”.

    • Activate the site setting enable twitter logins

    • Copy the Twitter API key in the twitter_consumer_key field and the Twitter API key secret in the twitter_consumer_secret field.

Rich Embeds

The above steps also apply if you want to enable “rich embedding” of tweets with pictures and more. If you want rich embeds but don’t need Twitter login, simply uncheck enable twitter logins and leave the consumer key and secret intact.

66 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.

2 Likes

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

2 Likes

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

5 Likes

The guide has been updated

8 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