驱动程序 [provider] 不支持 laravel/socialite

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45555003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:27:52  来源:igfitidea点击:

Driver [provider] not supported laravel/socialite

laravellaravel-socialite

提问by Dtp

I'm using Laravel 5.4 and Socialite 3.0

我正在使用 Laravel 5.4 和 Socialite 3.0

With every new socialite provider I add I get the error:

对于我添加的每个新社交名流提供商,我都会收到错误消息:

Driver [provider] not supported.

不支持驱动程序 [provider]。

for example when adding socialiteproviders/twitch 3.0 I will get the error:

例如,在添加 socialiteproviders/twitch 3.0 时,我会收到错误消息:

Driver [twitch] not supported.

不支持驱动程序 [twitch]。

However I can use a provider that's already built in to Socialite, github for example works as expected.

但是,我可以使用已经内置到 Socialite 中的提供程序,例如 github 可以按预期工作。

I have tried three different providers and I get the same result each time, what am I doing wrong?

我尝试了三个不同的提供商,每次都得到相同的结果,我做错了什么?

Here are my routes:

以下是我的路线:

Route::get('/auth/bnet', 'BnetController@redirectToProvider');

Route::get('/auth/bnet/return', function() {
    $user = Socialite::driver('battlenet')->user();
    dd($user->accessTokenResponseBody);
});

Route::get('/auth/git', function() {
    return Socialite::driver('github')->redirect();
});

Route::get('/auth/twitch', function() {
    return Socialite::with('twitch')->redirect();
});

Here's my $listen from my EventServiceProvider:

这是我的 EventServiceProvider 的 $listen:

    protected $listen = [
      \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // add your listeners (aka providers) here
        //'SocialiteProviders\Battlenet\BattlenetExtendSocialite@handle',
        'Reflex\SocialiteProviders\BattleNet\BattleNetExtendSocialite@handle',
        'SocialiteProviders\Twitch\TwitchExtendSocialite@handle',
      ],
    ];

I have added SocialiteProviders\Manager\ServiceProvider::class, to my providers array in app.php, I have added the Socialite facade ('Socialite' => Laravel\Socialite\Facades\Socialite::class,) to my aliases array also in app.php and have added the appropriate keys to my .env

我在 app.php 中将 SocialiteProviders\Manager\ServiceProvider::class, 添加到我的 providers 数组中,我还向我的别名数组添加了 Socialite 门面('Socialite' => Laravel\Socialite\Facades\Socialite::class,)在 app.php 中,并在我的 .env 中添加了适当的键

回答by Roman Spiridonov

I had the same issue and I found solution.

我有同样的问题,我找到了解决方案。

In config/app.php providers array:

在 config/app.php 提供者数组中:

'providers' => [
    // ...
    Laravel\Socialite\SocialiteServiceProvider::class,
    \SocialiteProviders\Manager\ServiceProvider::class,
    // ...
]

In app/Providers/EventServiceProvider.php:

在 app/Providers/EventServiceProvider.php 中:

protected $listen = [
// ...
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        'SocialiteProviders\VKontakte\VKontakteExtendSocialite@handle',
    ],
]

You missed \ at start of 'SocialiteProviders\Twitch\TwitchExtendSocialite@handle'.

您在“SocialiteProviders\Twitch\TwitchExtendSocialite@handle”开头错过了\。

回答by NathanL

Hopefully this helps someone, but I found that I had to separate the EventServiceProvider.php listen classes with "\\" instead of "\". Laravel 5.6. e.g:

希望这对某人有所帮助,但我发现我必须用“\\”而不是“\”分隔 EventServiceProvider.php 监听类。Laravel 5.6。例如:

protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        'SocialiteProviders\Twitch\TwitchExtendSocialite@handle',
        'SocialiteProviders\Podio\PodioExtendSocialite@handle',
    ],

If you're still struggling, triple-check to ensure all of the packages are installed.

如果您仍然在挣扎,请三重检查以确保安装了所有软件包。

I also found that including...

我还发现,包括...

Laravel\Socialite\SocialiteServiceProvider::class,

...in your config/app.php is not necessary when using SocialiteProviders\Manager.

...在您的 config/app.php 中使用 SocialiteProviders\Manager 时不是必需的。

回答by Adam Patterson

Make sure that you have updated config/services.phpto include the client_idclient_secretand redirectfrom your provider.

确保您已更新config/services.php以包含来自您的提供商的client_idclient_secretredirect

Clear your config and try again.

清除您的配置并重试。

回答by Bill Huertas

Adding an answer here because this question comes up while searching for the same error as it pertains to Lumen as well and I suspect others may run into the same issue that I did.

在此处添加答案是因为在搜索与 Lumen 相关的相同错误时会出现此问题,我怀疑其他人可能会遇到与我相同的问题。

The Lumen-specific documentationfor additional providers doesn't appear to mention some gotchas (at least, for my version of Lumen) and Lumen needs a little extra configuration to work compared to Laravel.

额外提供者的Lumen 特定文档似乎没有提到一些问题(至少,对于我的 Lumen 版本),与 Laravel 相比,Lumen 需要一些额外的配置才能工作。

I'm on Lumen 5.8.2 and had been becoming increasingly frustrated getting Socialite with additional providers set up - all of my configuration in bootstrap/app.phpand EventServiceProvider.phpseemed correct (and was) until I realized that Lumen wasn't actually registering the EventServiceProvideritself.

我在流明5.8.2,并已变得越来越沮丧越来越社会名流与设置其他提供商-我所有的配置bootstrap/app.phpEventServiceProvider.php似乎正确的(并且是),直到我意识到流明实际上并没有注册的EventServiceProvider本身。

To remedy this problem, register the EventServiceProvider within your bootstrap/app.phpsetup:

要解决此问题,请在您的bootstrap/app.php设置中注册 EventServiceProvider :

$app->register(App\Providers\EventServiceProvider::class);

$app->register(App\Providers\EventServiceProvider::class);

With the EventServiceProvider registered, just refer to the other answers here to configure events, the provider's service config and registering Socialite in app.php and you ought to be good to go.

注册 EventServiceProvider 后,只需参考此处的其他答案来配置事件、提供者的服务配置和在 app.php 中注册 Socialite 就可以了。