2017 © Pedro Peláez
 

library baidusocialite

openapi.baidu.com OAuth2 Provider for Laravel Socialite

image

boolw/baidusocialite

openapi.baidu.com OAuth2 Provider for Laravel Socialite

  • Thursday, January 5, 2017
  • by boolw
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

baidusocialite

openapi.baidu.com OAuth2 Provider for Laravel Socialite, (*1)

<, (*2)

h6>百度认证(Baidu), (*3)

<, (*4)

h6> 使用如下Composer命令安装依赖:, (*5)

composer require boolw/baidusocialite

注册服务提供者(同时注释掉原有的Socialite提供者):, (*6)

//Laravel\Socialite\SocialiteServiceProvider::class,
SocialiteProviders\Manager\ServiceProvider::class,

添加Socialite门面(如果已有略过本操作):, (*7)

'Socialite' => Laravel\Socialite\Facades\Socialite::class,

添加事件监听器(App/Providers/EventServiceProvider):, (*8)

protected $listen = [
    'SocialiteProviders\Manager\SocialiteWasCalled' => [
        'SocialiteProviders\Weibo\WeiboExtendSocialite@handle',
    ],
];

去新浪微博开放平台(https://openapi.baidu.com/)创建一个新的网站应用以获取相应的App Key和App Secret。需要注意的是不比GitHub,新浪微博需要创建的网站应用对应网站在外网可以访问。, (*9)

然后在配置文件app/services.php中添加weibo配置项:, (*10)

'baidu' => [
    'client_id' => 'your weibo app App Key',
    'client_secret' => 'your weibo app App Secret',
    'redirect' => 'http://laravel.app:8000/auth/baidu/callback'
]

接下来我们要对AuthController略作修改:, (*11)

public function redirectToProvider(Request $request,$service)
{
    return Socialite::driver($service)->redirect();
}

public function handleProviderCallback(Request $request,$service)
{
    $user = Socialite::driver($service)->user();
    dd($user);
}

以支持多种不同认证提供者的切换。, (*12)

最后需要修改认证路由规则如下:, (*13)

Route::get('auth/{service}', 'Auth\AuthController@redirectToProvider');
Route::get('auth/{service}/callback', 'Auth\AuthController@handleProviderCallback');

至此就可以在浏览器中访问http://laravel.app:8000/auth/baidu进行测试了。, (*14)

The Versions

05/01 2017

1.0.x-dev

1.0.9999999.9999999-dev

openapi.baidu.com OAuth2 Provider for Laravel Socialite

  Sources   Download

MIT

The Requires

 

by Avatar boolw

05/01 2017

2.0

2.0.0.0

openapi.baidu.com OAuth2 Provider for Laravel Socialite

  Sources   Download

MIT

The Requires

 

by Avatar boolw

05/01 2017

dev-master

9999999-dev

openapi.baidu.com OAuth2 Provider for Laravel Socialite

  Sources   Download

MIT

The Requires

 

by Avatar boolw

05/01 2017

1.0

1.0.0.0

openapi.baidu.com OAuth2 Provider for Laravel Socialite

  Sources   Download

MIT

The Requires

 

by Avatar boolw