Использую 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'