ClientException Client error: `GET https://www.googleapis.com/plus/v1/people/me?prettyPrint=false` resulted in a `403 Forbidden` response:

  google-api, laravel

when I wanna login with google account, I receive this error,

ClientException Client error: GET https://www.googleapis.com/plus/v1/people/me?prettyPrint=false
resulted in a 403 Forbidden response:
<meta name=viewport content="initial-scale=1,
minimum-scale=1, w (truncated…) in RequestException.php line 113

 public function redirectToProvider()
    {
        return Socialite::driver('google')->redirect();
    }



    public function handleProviderCallback()
    {
        $social_user = Socialite::driver('google')->user();

        $user = User::whereEmail($social_user->getEmail())->first();


        if( ! $user ) {
            $user = User::create([
                'name' => $social_user->getName(),
                'email' => $social_user->getEmail(),
                'password' => bcrypt($social_user->getId())
            ]);
        }

        if($user->active == 0) {
            $user->update([
                'active' => 1
            ]);
        }

        auth()->loginUsingId($user->id);
        return redirect('/');
    }

Source: Laravel

Leave a Reply