Laravel Socialite 的 Pushbullet OAuth2 提供程序

4.1.0 2020-12-01 23:10 UTC

This package is auto-updated.

Last update: 2024-08-26 21:38:52 UTC


README

composer require socialiteproviders/pushbullet

安装与基本使用

请参阅 基本安装指南,然后按照以下特定提供程序的说明操作。

config/services.php 中添加配置

'pushbullet' => [    
  'client_id' => env('PUSHBULLET_CLIENT_ID'),  
  'client_secret' => env('PUSHBULLET_CLIENT_SECRET'),  
  'redirect' => env('PUSHBULLET_REDIRECT_URI') 
],

添加提供程序事件监听器

Laravel 11+

在 Laravel 11 中,默认的 EventServiceProvider 提供程序已被移除。相反,您可以在您的 AppServiceProviderboot 方法中使用 Event 门面上的 listen 方法添加监听器。

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

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

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

使用方法

现在您应该能够像通常使用 Socialite 一样使用提供程序(假设您已安装门面)。

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

返回的用户字段

  • id
  • name
  • email
  • avatar