Answer the question
In order to leave comments, you need to log in
Why does Google authentication API throw an Invalid state error?
I use knpu university bundle
/**
* @Route("/connect-google", name="connect_google_start")
* @param ClientRegistry $clientRegistry
* @return Response
*/
public function connectFacebookAction(ClientRegistry $clientRegistry): Response
{
return $clientRegistry
->getClient('google_main')
->redirect([
'profile', 'email'
], []);
}
/**
* @Route("/google-check", name="google_check")
*
* @param Request $request
* @param ClientRegistry $clientRegistry
* @return RedirectResponse
*/
public function connectGoogleCheckAction(Request $request, ClientRegistry $clientRegistry)
{
$client = $clientRegistry->getClient('google_main');
try {
//be sure you use dev.pro VPN
$user = $client->fetchUser();
//В этом участке кода ошибка
exit;
$this->googleService->storeOrAuth($user, $request);
} catch (IdentityProviderException $e) {
$this->logger->error('Google authorization: ' . $e->getMessage());
}
return $this->redirectToRoute('home');
}
google_main:
type: google
client_id: '%env(OAUTH_GOOGLE_ID)%'
client_secret: '%env(OAUTH_GOOGLE_SECRET)%'
redirect_route: google_check
redirect_params: {}
access_type: 'offline'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question