I am working on social login in Laravel. When passing parameter for identifying sign in and signup, it occurs error.
“accounts.google.com redirected you too many times.”
Without a parameter, it works well.
These are my router.
Route::get('/login/google', 'AuthLoginController@google')->name('login.google'); //working well Route::get('/login/google/{method}', 'AuthLoginController@google')->name('login.google'); //not working Route::get('/login/google/redirect', 'AuthLoginController@googleRedirect');
This is my controller.
<?php namespace AppHttpControllersAuth; use AppHttpControllersController; use IlluminateFoundationAuthAuthenticatesUsers; use Socialite; class LoginController extends Controller { private $googleSign = ''; //public function google() //working well public function google($method) //not working { $this->googleSign = $method; return Socialite::driver('google')->redirect(); } public function googleRedirect() { $user = Socialite::driver('google')->stateless()->user(); }
This is my view.
<a href="{{ route('login.google', 'signin') }}"> Sign in with Google </a>
Advertisement
Answer
I just found a route issue.
Route::get('/login/google/{method}', 'AuthLoginController@google')->name('login.google'); Route::get('/login/googleRedirect', 'AuthLoginController@googleRedirect');