Laravel Socialite 的事件组织者 OAuth2 提供者

4.1.0 2020-12-01 23:10 UTC

This package is auto-updated.

Last update: 2024-08-26 21:30:17 UTC


README

composer require socialiteproviders/eventbrite

安装与基本使用

请参阅基础安装指南,然后按照以下特定提供者的说明进行操作。

config/services.php 中添加配置

'eventbrite' => [    
  'client_id' => env('EVENTBRITE_CLIENT_ID'),  
  'client_secret' => env('EVENTBRITE_CLIENT_SECRET'),  
  'redirect' => env('EVENTBRITE_REDIRECT_URI') 
],

添加提供者事件监听器

Laravel 11+

在 Laravel 11 中,默认的 EventServiceProvider 提供者已被移除。相反,您需要在 AppServiceProviderboot 方法中使用 Event 面具的 listen 方法添加监听器。

  • 注意:除非您用自己提供的提供者覆盖了内置的社交提供者,否则您不需要添加任何内容。
Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
    $event->extendSocialite('eventbrite', \SocialiteProviders\Eventbrite\Provider::class);
});
Laravel 10 或以下配置包的监听器以监听 `SocialiteWasCalled` 事件。

app/Providers/EventServiceProvider 中的 listen[] 数组中添加事件。有关详细说明,请参阅基础安装指南

protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
        \SocialiteProviders\Eventbrite\EventbriteExtendSocialite::class.'@handle',
    ],
];

使用方法

现在您应该能够像通常使用 Socialite 一样使用此提供者(假设您已安装了 facade)

return Socialite::driver('eventbrite')->redirect();

返回的用户字段

  • id
  • name
  • email