laravel / socialite

Laravel wrapper around OAuth 1 & OAuth 2 libraries.

Home Page:https://laravel.com/docs/socialite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot use both Twitter and Twitter OAuth 2 at the same time

haltsir opened this issue · comments

  • Socialite Version: 5.5.4
  • Laravel Version: 9.25.1
  • PHP Version: 8.1.8
  • Database Driver & Version: MySQL 5.7

Description:

When configuring Socialite in config/services.php, if I use both the twitter driver and the twitter-oauth-2 driver, then the config files gets mixed up - twitter-oauth-2 receives the values from the twitter driver and not its own. This prevents from having a system use both drivers at the same time.

Steps To Reproduce:

Install Laravel with Socialite. Configure both twitter and twitter-oauth-2 drivers. Check client_id and client_secret values for both (they are the same).

I'd be interested to know what reason you have for supporting both OAuth version for Twitter.

Regardless this problem is caused by the code used to resolve the config for the driver here

$config = $this->config->get('services.twitter') ?? $this->config->get('services.twitter-oauth-2');

@taylorotwell @driesvints It looks like swapping this logic around to check for the oauth-2 config first should solve the problem here – though I'm not sure if this is a breaking change or not?

$config = $this->config->get('services.twitter-oauth-2') ?? $this->config->get('services.twitter');

@joelbutcher wouldn't that just swap the problem to the other driver?

Right now, we don't support using both at the same time, sorry. We could look into it but it would be for the next version. I also think the original Twitter OAuth service doesn't really hold value anymore unless you can explain otherwise.

The original OAuth service holds information that v2 does not. For example user information - avatars, banners, etc. There are some v1.1 endpoints that doesn't work with OAuth2 context. Please resolve this bug. When is the next version expected?

No plans for a next version right now

So you're basically telling me that you know there's a bug, but you have absolutely no intention of fixing it? You can see why that would make anyone that stumbles upon this mad, right?

I don't know of any bug. It's just not possible to use these two drivers at the same time. You can write a custom driver of your own if you want to use the two at the same time.

If you can't use both drivers at the same time, this is a bug. It's a functionality provided as-is from the package that doesn't work. It's like saying that twitter and facebook drivers doesn't work together and this is not a bug.

@joelbutcher wouldn't that just swap the problem to the other driver?

@driesvints No, since the code is located within the createTwitterOAuth2Driver() method which is only responsible for building the driver for the OAuth 2 driver. Twitter OAuth 1 shouldn't be affected

If you can't use both drivers at the same time, this is a bug. It's a functionality provided as-is from the package that doesn't work. It's like saying that twitter and facebook drivers doesn't work together and this is not a bug.

Definitely a bug. I can point out a few other bugs with Socialite/Laravel but it is too tiresome tbh. It is clear Laravel only cares about appearance and closes issues ASAP regardless of their legitimacy.

I have learned to be very conservative with this framework and not try to extend functionalities.
It only comes back to bite when you think you've almost made a hack to work around the framework, then hit an unexpected 500 line stack trace that looks like hieroglyphics.