Configure Twitter login and rich embeds for Discourse

To be totally fair to the Discourse team, this is different from the issue in December 2020. That very last post for that different issue was right before @dnfoz’s first post here, and it was from over a year ago. @dnfoz’s issue was just posted 8 days ago, not months ago. The problem is Twitter is constantly changing their API because they—quite frankly—have no idea what they are aiming for with their platform. That is why one issue a year ago will be totally different from one, say, a week ago, with Twitter in particular. And if this was an issue months ago, outside of osmosis and reading minds, you or someone would have had to post about it so they know.

2 Likes

It seems to work except on signup it doesn’t fill the email field automatically? Am I doing something wrong? Works with my google signup, where it populates email automatically.

1 Like

See @dnfoz’s example. It is down to the fact that every SSO provider is different, meaning how Google does it is a bit different than Twitter, and Twitter is among the worst if not the worst. Twitter’s API is a moving target because Twitter doesn’t know what the heck they are doing and Twitter shows no courtesy to the developers building around their API. So, being brutally honest with you, unless us Discourse admins or the Discourse team are constantly birddogging this plug-in for changes upstream on Twitter’s end, it will constantly break like this.

2 Likes

Thanks for this. Yes I don’t think I should waste any more time learning and fiddling with Twitter APIs that as you say might change at any point. I am sure my users will cope!

2 Likes

That is not to say the Discourse Team isn’t already working on a fix, which they are, and it may not require anything more than updating the plug-in for it to work again on the admin end. The problem is this is a habitual issue with Twitter because they are a poorly managed corporation. I will keep my Twitter SSO plugin in place still as an option but Twitter definitely isn’t a safe and dependable option like any of the other SSOs.

1 Like

If we are still having these issues, can we try to reproduce the same issue on try.discourse.org? I was able to log in fine with my Twitter account there.

4 Likes

Wow, signing up with Twitter at the try subdomain forum you just shared seemed to work with flying colors. That really makes me wonder if there is a plugin collision or something unique configuration-wise going on here.

2 Likes

So strange. I am still getting the weird behavior on my website. It’s production, so I cannot toggle too many things, but I will do my best to try to figure it out. It must not be all that unique if other users are also reporting this though.

1 Like

Compared to the parent post here, Twitter has visually changed how settings are configured. This is what I have configured (the setting that are safe to share publicly here in the forum anyway) for my Discourse instance, at least:

EDIT: This might be something. While there is still an option for requesting email from users, there is no longer a setting for Enable 3rd party authentication as mentioned in the parent post. For people who had configured their Twitter login prior to this change in their settings, this might not be a problem since Twitter might grandfather them in and migrate their settings. However, I am not seeing this option anymore which may pose a problem for users like myself and @dnfoz who are configuring our forums for the first time and Discourse needs to have third party authentication to successfully complete the SSO handshaking process.

EDIT 2: Here is another thing to chew on. Is Discourse expecting Twitter API v1 or v2? For new developers, they no longer offer v1 as they only mention migrating for those who were already using v1 with no mention of legacy v1 support for new users. See details here:

As described at the link above, it would seem that they only allow preexisting developer accounts to migrate v1 over. I see no way or documentation for enabling v2 on new developer accounts and therefore I only have v2 support.

So, assuming the SSO and embedding is expecting Twitter API v1, this may require some coding effort to support both API releases or sunsetting v1 support if such a dual-pronged approach isn’t possible.

EDIT 3: So in reading Twitter’s Twitter Developers Discourse forum (oh, the irony that Twitter themselves uses Discourse!), my suspicions seem to be all but confirmed. According to their pinned banner (viewable here: Twitter Developers (twittercommunity.com)), new developers cannot access the v1.1 API:

Are you new to the platform and ready to get started?

We encourage you to sign up for Essential access and make your first request to the API.

Once you sign up, you will have a project with Essential access within your account which will provide you with the following:

  • 1 App environment
  • The ability to retrieve up to 500k Tweets per month
  • The ability to use up to 5 rules with the filtered stream endpoint
  • Access to the majority of the Twitter API v2 endpoints
  • You will not be able to access the standard v1.1, premium v1.1, or enterprise endpoints
3 Likes

Yes this is exactly what I am getting at songwritingsteps.com - it fills in “user1” and no email.

Please let me know if you figure it out! I was banging my head against the wall for hours :confused:

1 Like

Nope, no idea! I can always spin up a forum in a VM on my local machine and see if I can figure out what’s up, though. As it stands though, no leads yet. I am shooting in the dark but as mentioned I suspect it is expecting V1 API support that is culprit. The necessary V1 legacy support just isn’t there anymore for new developer accounts as I just shared.

1 Like

Thanks! This is great digging @Hifihedgehog. We’re looking into the best path forward and will provide an update when we have one.

Thanks for your patience everyone.

2 Likes

I don’t think that you can configure social logins on a local machine. You need a valid https certificate. Do you have a valid cert to access the vm on your local machine?

1 Like

Actually, it’s not too tricky: I could set up an SSH tunnel to my local machine from my VPS and then point it to a proxy across my webserver that has an SSL certificate already on it. :wink:

3 Likes

Ok, I think we were able to solve the mystery :mag_right:

As @Hifihedgehog pointed out, new Twitter developer accounts start out on the “Essential” plan and are limited to the v2 API endpoints. Our built-in Twitter login currently needs to access v1.1 endpoints. Thankfully that’s not a problem!

There are two important things to note on this chart at Twitter API | Products | Twitter Developer Platform

You can gain access to the v1.1 API for free under the Elevated plan. You simply need to apply from your developer dashboard. I found it very quick and easy. Discourse Twitter logins worked flawlessly after that :tada:

I’ll update the OP to include this newfound requirement.

10 Likes

Boy, are you right! That took all of a couple minutes and I was instantly approved. Simple fixes are always nice! :smile:

5 Likes

8 posts were split to a new topic: Quoting broken when name matches username

If the Twitter secret or key is updated, does it impact existing users? If so is there a way to “fix” it, I found these instruction for Facebook login updates, would this be the right script to use?

cd /var/discourse
./launcher enter app
rails c
UserAssociatedAccount.where(provider_name: "twitter").delete_all

My twitter links are not being embedded anymore after setting up twitter login. I first setup twitter consumer keys, login didn’t work as expected. Now I am on the “Elevated” plan so I should have v1.1 endpoint access.

Login now works as expected, but when I rebuild a post with twitter links, they just stay as plain links.

When I rebuild an old post which already has tweets embedded, the embeds get removed.

Any clue?

EDIT: This seems to got fixed in the most recent update (2.9.0.beta5 - 0ae7b43018)

1 Like

I’m having a problem with this, in that images appear broken. Example:

Any thoughts…? Everything is up to date :confused:

1 Like