Manager icon indicating copy to clipboard operation
Manager copied to clipboard

Overriding config does not work for oauth1 providers

Open Coding-Kiwi opened this issue 3 years ago • 4 comments

Issue / Motivation:

"laravel/socialite": "^5.5" "socialiteproviders/trello": "^4.1"

As specified in the documentation, you can override the config like this:

$config = new \SocialiteProviders\Manager\Config($clientId, $clientSecret, $redirectUrl, $additionalProviderConfig);
return Socialite::driver('trello')->setConfig($config)->redirect();

Sadly setConfig specified in https://github.com/SocialiteProviders/Manager/blob/master/src/OAuth1/AbstractProvider.php#L149 does only modify the config object, but not the clientCredentials (League\OAuth1\Client\Credentials\ClientCredentialsInterface) inside the server (League\OAuth1\Client\Server\Server)

Expected behavior:

Calling setConfig changes the config of the provider that is later on used by the redirect call

Actual behavior:

Calling setConfig leaves the values inside the OAuth1 Server instance (which seem to be the values that are actually used by the redirect call) untouched

Steps to reproduce the behavior:

  1. install socialiteproviders/trello
  2. try to assign a new config with different redirect uri for example
  3. redirect call still uses the values from config.php

Proposed solution:

Pseudocode:

#SocialiteProviders\Manager\OAuth1\AbstractProvider

public function setConfig(Config $config){
      $this->config = $this->server->setConfig($config);

      if($this->server instanceof League\OAuth1\Client\Server\Server){
            $credentials = $this->server->getClientCredentials();
            $credentials->setIdentifier($config->get()["client_id"]);
            $credentials->setSecret($config->get()["client_secret"]);
            $credentials->setCallbackUri($config->get()["redirect"]);
      }

      return $this;
 }

Coding-Kiwi avatar Feb 15 '22 12:02 Coding-Kiwi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 17 '22 11:04 stale[bot]

is this project dead or is it simply the wrong place to post an issue regarding socialite?

Coding-Kiwi avatar Apr 21 '22 20:04 Coding-Kiwi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 28 '22 00:06 stale[bot]

bump

Coding-Kiwi avatar Jun 30 '22 18:06 Coding-Kiwi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 20 '22 19:09 stale[bot]