建站篇-用户认证系统-第三方平台账号登陆
这里拿Github账号登陆做演示
首先安装
composer require laravel/socialite在app.php里添加ServiceProvider 和 alias
Laravel\Socialite\SocialiteServiceProvider::class,
'Socialite'=>Laravel\Socialite\Facades\Socialite::class,在config/services.php 中添加
'github'=>[获取方法参考:https://github.com/settings/applications
'client_id'=>'your_client_id',
'client_secret'=>'your_client_secret',
'redirect'=>'your_callback_url',
],
添加路由:
Route::get('login/github','Auth\LoginController@redirectToGithubLogin');添加方法:
Route::get('login/github/callback','Auth\LoginController@githubLoginCallback');
文章图片
然后访问login/github即可
如果出现cURL error 60: SSL certificate: unable to get local issuer certificate这样的错误
下载文件https://gist.github.com/VersatilityWerks/5719158/download放到D:\wamp64\bin\php\php7.0.0\extras\ssl\cacert.pem(参考)
然后修改php.ini的curl.cainfo字段信息为= "D:\wamp64\bin\php\php7.0.0\extras\ssl\cacert.pem"
(注意 文件名.扩展名 一定要完全对应)
===================================================
现在只是验证了第三方登陆的可行性,接下来继续改造。
LoginController
文章图片
新建BindController
文章图片
文章图片
【建站篇-用户认证系统-第三方平台账号登陆】新建bind.blade.php
文章图片
更新路由
文章图片
OK
。
推荐阅读
- 2018年11月19日|2018年11月19日 星期一 亲子日记第144篇
- 《魔法科高中的劣等生》第26卷(Invasion篇)发售
- 拍照一年啦,如果你想了解我,那就请先看看这篇文章
- 亲子日记第186篇,2018、7、26、星期四、晴
- 漫画初学者如何学习漫画背景的透视画法(这篇教程请收藏好了!)
- 两短篇
- 第四十三篇接纳孩子的感受
- 感恩日记第111篇2020.02.06
- 2018年8月25日|2018年8月25日 星期六 晴 亲子日记第259篇
- 25篇中考随笔