Level 67
@madan_para Not sure if this will help but check the answers here:
https://stackoverflow.com/questions/30660847/laravel-socialite-invalidstateexception
I am trying to integrate Google Login in my web app. When I enter my google account and password, after that the upper error comes. I don't know why this error is coming. I have used some of the solutions in the Stackoverflow but it is still unsolved.
My GoogleController is :
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Socialite;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
class GoogleController extends Controller
{
public function redirectToGoogle()
{
return Socialite::driver('google')->redirect();
}
public function handleGoogleCallback()
{
try{
$user = Socialite::driver('google')->user();
//dd($user);
$finduser = User::where('google_id',$user->id)->first();
if($finduser) {
Auth::login($finduser);
return redirect('home');
}else{
$newUser = User::create([
'name' => $user->name,
'email' => $user->email,
'google_id' => $user->id,
'password' => encrypt('123456dummy')
]);
Auth::login($newUser);
return redirect('home');
}
} catch(Exception $e) {
dd($e->getMessage());
}
}
}
Please tell me any solution .
Please or to participate in this conversation.