Laravel Socialite:使用LinkedIn登录会在Cancle按钮上出现错误

时间:2018-04-05 12:29:11

标签: php laravel linkedin-api laravel-socialite

我已按照以下链接在我的laravel应用中提供Login With LinkedIn

https://itsolutionstuff.com/post/laravel-5-login-with-linkedin-using-socialite-packageexample.html

全部工作正常,我已成功登录于likesin。

但问题是当用户第一次点击我的网站上的Login With Linked按钮时,它会重定向到链接页面显示带Ok和Cancle按钮的Dialog,现在如果用户点击cancle按钮,则显示错误

enter image description here

浏览器网址为:

  

http://www.mywebsite.com/auth/linkedin/callback?error=user_cancelled_login&error_description=The+user+cancelled+LinkedIn+login&state=NSlF7oA3yFRLCoRi5BARhbVrWwK8b02Mg54Jw5cg

我想当用户点击cancle按钮时,它只是重定向到我网站的主页。

在LinkedIn Developer Console上我添加了以下网址:

OAuth 2.0

授权重定向网址:

http://www.mywebsite.com/auth/linkedin/callback

OAuth 1.0a

默认"接受"重定向网址:

http://www.mywebsite.com/auth/linkedin

默认"取消"重定向网址:

http://www.mywebsite.com/

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

你应该试试这个:

在Contoller方法中,为http://www.mywebsite.com/auth/linkedin/callback

调用withch
if($request->has('error')){
 return redirect()
             ->to('admin/login')
             ->withErrors("Access Denied");
}