Configure Twitter login (and rich embeds) for Discourse

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

Finally ‘fixed’ the site (migrated from phpbb Tuesday) and got embed to work, but the size is crazy - anyone know the fix for that?

1 Like

They have recently added Environment setting.

My app is set to Development. There are two other options: Production and Staging.

Should I change to either of the two?

1 Like

Edit: Used the wrong keys lol fixed it

Is there a way to rebuild posts that have Twitter links before the API was set up? Not a huge deal if there’s no way to retroactively embed them but would be cool

1 Like

how you fix it? my link are broken

1 Like

I can’t get approved, what did you do to get it so fast?