加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – 在laravel 5上使用Socialite-package for Linkedin登录

发布时间:2020-12-14 19:37:19 所属栏目:大数据 来源:网络整理
导读:我目前正尝试使用社交网站使用LinkedIn创建身份验证,但我在LinkedIn上创建应用程序并在其上添加回调URL,如下所示: http://localhost:8080/callback/linkedin 并在config / services.php上添加: 'linkedin' = [ 'client_id' = 'xxxxx','client_secret' = 'x
我目前正尝试使用社交网站使用LinkedIn创建身份验证,但我在LinkedIn上创建应用程序并在其上添加回调URL,如下所示:

http://localhost:8080/callback/linkedin

并在config / services.php上添加:

'linkedin' => [
        'client_id'     => 'xxxxx','client_secret' => 'xxxxx','redirect'      => 'http://localhost:8080/callback/linkedin',],

我也创建了路由和功能(我为Facebook做了这个,谷歌它工作正常没有问题)
但是,当我尝试将它用于LinkedIn时,我收到此错误:

InvalidArgumentException in Manager.php line 92: Driver [linkedin] not supported.

NT:在Socialite包文档上他们说包支持linkedIn

Official Documentation

In addition to typical,form based authentication,Laravel also
provides a simple,convenient way to authenticate with OAuth providers
using Laravel Socialite. Socialite currently supports authentication
with Facebook,Twitter,LinkedIn,Google,GitHub and Bitbucket.

解决方法

@路线

//social links integrations
Route::get('/social/linkedin/redirect','SocialAuthController@redirectToProvider');
Route::get('/social/linkedin/callback','SocialAuthController@handleProviderCallback');

@Controller代码

public function redirectToProvider() {

     return Socialite::driver('linkedin')->redirect();
}


public function handleProviderCallback(Request $request){

    try {
        $provider_user = Socialite::driver('linkedin')->user();
    } catch ( Exception $e ) {
        $request->session()->flash( 'alert-danger','Invalid request data detected! please try again.' );
        return redirect( '/' );
    }

    dd($provider_user);

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读