Search code examples
phplaravelgoogle-apilaravel-9laravel-socialite

Laravel 9: Socialite: cURL error 7: (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://www.googleapis.com/oauth2/v4/token"


I have been struggling for the past week with this error, and I cannot find one like mine online. I am developing an application with Laravel 9 that let the user log in using the Google Account.

Furthermore, I am no expert using Laravel, so I followed this tutorial online:

https://www.itsolutionstuff.com/post/laravel-9-socialite-login-with-google-account-exampleexample.html

I finished this tutorial and everything seems to work; however, when I log in using a Google Account and receiving the callback this cURL error shows up

"cURL error 7: (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://www.googleapis.com/oauth2/v4/token" // app/Http/Controllers/GoogleController.php:55

For more info about my Code, this is the web.php

Route::controller(GoogleController::class)->group(function(){
  Route::get('auth/google', 'redirectToGoogle')->name('auth.google');
  Route::get('auth/google/callback', 'handleGoogleCallback');
});

services.php

'google' => [
    'client_id' => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => 'https://mywebsite.com/auth/google/callback'
]

enter image description here


Solution

  • This error was because SELinux Blocked the Application. It is fixed now.