duocircle / remoteauth-socialite-provider
Laravel Socialite 的远程身份验证 OAuth2 提供程序
1.0.2
2019-02-11 05:52 UTC
Requires
- php: >=5.5.9
- socialiteproviders/manager: ^3.0
This package is auto-updated.
Last update: 2024-09-08 09:14:51 UTC
README
Laravel Socialite 为 RemoteAuth 提供程序
安装
1. Composer
通过 composer 将包添加到您的 Laravel 项目中
composer require owenconti/remoteauth-socialite-provider
2. 添加事件和监听器
-
将
SocialiteProviders\Manager\SocialiteWasCalled
事件添加到<app_name>/Providers/EventServiceProvider
中的listen[]
数组。 -
将监听器
'\SocialiteProviders\RemoteAuth\RemoteAuthExtendSocialite@handle'
添加到SocialiteProviders\Manager\SocialiteWasCalled[]
。
例如
protected $listen = [ ... \SocialiteProviders\Manager\SocialiteWasCalled::class => [ ... '\SocialiteProviders\RemoteAuth\RemoteAuthExtendSocialite@handle', ], ];
4. 环境变量
将提供者值追加到您的 .env
文件中(您可以在 RemoteAuth 应用程序仪表板中找到它们)
REMOTEAUTH_CLIENT_ID=your_client_id
REMOTEAUTH_CLIENT_SECRET=your_client_secret
5. 添加配置变量
将以下配置值追加到 config/services.php
'remoteauth' => [
'client_id' => env('REMOTEAUTH_CLIENT_ID'),
'client_secret' => env('REMOTEAUTH_CLIENT_SECRET'),
'redirect' => config('app.url') . '/callback'
]
6. 使用测试服务器
如果您在非生产环境中工作,我们建议您使用 RemoteAuth 沙箱服务器:https://sandbox.remoteauth.com。您可以通过以下方式将 Socialite 提供程序指向沙箱服务器:
// .env
REMOTEAUTH_URL=https://sandbox.remoteauth.com
// config/services.php
'remoteauth' => [
'url' => env('REMOTEAUTH_URL')
]