Laravel socialite 3.0 google return 403 - Forbidden

浪尽此生 提交于 2019-12-12 18:33:01

问题


I am using Laravel 5.6 and socialite 3.0. I have created google API from developer console and enable for Gmail API and google plus. please check screen shot.

Also, I have to make setup inside .env file.

Google callback return 403 error code

I have created class and method

public function redirect($provieder)
{
     return Socialite::driver($provieder)->redirect();
}

public function callback($provieder)
{           
    try{
        $user = Socialite::driver($provieder)->stateless()->user();
        if (isset($user)) {
            $social = $this->createUser($user,$provieder);
            return redirect()->route('profile.fill','location');
        }
        return redirect()->route('user.signup');
    }catch (Exception $e) {
        return redirect('auth/google');
    }
 }

I have create route file

Route::get('auth/{provider}', 'OAuth\SocialController@redirect');
Route::get('auth/{provider}/callback', 'OAuth\SocialController@callback');

回答1:


You had to activate the Google+ API from the Google Developers Console.

It was indeed an HTTP 403 Forbidden response.

I learned a bit more about "ClientException"... it is thrown by Guzzle's HTTP client, and it contains a few useful properties, mainly request and response:

try {
    $user = Socialite::driver('google')->user();
}
catch (GuzzleHttp\Exception\ClientException $e) {
     dd($e->response);
}



回答2:


This error says that the server could understand the request from the client, but it refuses to proceed with further actions with the request. It is often displayed when the server is configured to deny the client’s request for some reason.

The causes behind 403 error page

If the URL you’ve entered is correct, then it can be any of the following three reasons.

1) No index page

2) Empty html directory

3) Poor permission configuration or ownership issues.

The above listed are the most common reasons of 403 forbidden error.

check that link for how to fix it



来源:https://stackoverflow.com/questions/53725020/laravel-socialite-3-0-google-return-403-forbidden

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!