caesar-dev / socialite-provider-word-press-custom-endpoint

Laravel Socialite 的 WordPress OAuth2 提供者

4.2 2021-01-29 14:13 UTC

This package is auto-updated.

Last update: 2024-09-04 15:55:21 UTC


README

我们在 https://wp-oauth.com/(至少我想是这样)上使用它

composer require CaesarDev/SocialiteProviderWordPressCustomEndpoint

安装与基本用法

请参阅 基础安装指南,然后遵循以下特定于提供者的说明。

config/services.php 中添加配置

'wordpress' => [
    'client_id' => env('WORDPRESS_KEY'),
    'client_secret' => env('WORDPRESS_SECRET'),
    'redirect' => env('WORDPRESS_REDIRECT_URI'),  
    'api_top_endpoint' => env('WORDPRESS_API_TOP_ENDPOINT'),
    'api_endpoint' => env('WORDPRESS_API_ENDPOINT'),
],

添加提供者事件监听器

配置包的监听器以监听 SocialiteWasCalled 事件。

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

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

用法

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

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

返回的用户字段

  • id
  • 昵称
  • 名字
  • 电子邮件
  • 头像