So, I am trying to use the Google Login API for my web application. But the problem is, it doesn't work. I successfully installed the package Socialite and Auth. My Google OAuth2.0 is setuped. But when I click on the button Login with google, it gives me an error that I understand, but don't know how to fix. I'm searching this error for now 2 days on internet and I didn't find anything, that's why I'm posting now. Can someone help me ? Or put me on the right track :) I am using Laravel 8.0
Here is the problem that I get
Here is the function (both gives the same error)
public function redirectToProvider($provider)
{
return Socialite::driver($provider)->redirect();
//return($provider);
}
public function handleProviderCallback($provider)
{
$user = Socialite::driver($provider)->stateless()->user();
$authUser = $this->findOrCreateUser($user, $provider);
Auth::login($authUser, true);
return $user->token;
}
services.php
'google' => [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
'redirect' => env('GOOGLE_REDIRECT')
],
.env
GOOGLE_CLIENT_ID=XXXXXXXXXXXXXX.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=XXXXXXXXXXXXXXX
GOOGLE_REDIRECT=https://www.trivos.ca/home
I simply needed to run php artisan config:clear