Laravel Google OAuth 2禁止回叫403

时间:2018-12-20 11:35:00

标签: laravel laravel-5 laravel-socialite

我正在尝试实施Google OAuth登录。我将重定向到google登录页面。但是登录后,它将重定向到路由中定义的路径,并显示403错误代码。

http://labstoclinic.com/login/google/callback?state=access&code=4%2FtwCGdNaAZXluKqUiG4aPpUsghLLltF9hTMw9z-7ftDrcEulSSGXSpbMJv8BFgH6xD79ZrW_9NX9HalEzrDcC5Mo&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile#

URL上方是浏览器返回URL。

在路由文件中定义的路径是:

 Route::get('login/google/callback', 'OAuth\SocialController@googleHandleProviderCallback');

回调函数

 public function googleHandleProviderCallback()
{
    $googleUser = Socialite::driver('google')->user();
    echo "<pre>"; print_r($googleUser); exit;
}

1 个答案:

答案 0 :(得分:-1)

看看另一篇文章,看起来和您的问题相同: socialite laravel authantication error with google API