diff --git a/src/SocialiteManager.php b/src/SocialiteManager.php index 5da5863f..15b35483 100644 --- a/src/SocialiteManager.php +++ b/src/SocialiteManager.php @@ -113,6 +113,24 @@ protected function createGitlabDriver() )->setHost($config['host'] ?? null); } + /** + * Create an instance of the specified driver. + * + * @return \Laravel\Socialite\One\AbstractProvider + */ + protected function createTwitterDriver() + { + $config = $this->config->get('services.twitter'); + + if (($config['oauth'] ?? null) === 2) { + return $this->createTwitterOAuth2Driver(); + } + + return new TwitterProvider( + $this->container->make('request'), new TwitterServer($this->formatConfig($config)) + ); + } + /** * Create an instance of the specified driver. * @@ -143,20 +161,6 @@ public function buildProvider($provider, $config) ); } - /** - * Create an instance of the specified driver. - * - * @return \Laravel\Socialite\One\AbstractProvider - */ - protected function createTwitterDriver() - { - $config = $this->config->get('services.twitter'); - - return new TwitterProvider( - $this->container->make('request'), new TwitterServer($this->formatConfig($config)) - ); - } - /** * Format the server configuration. *