I have an application that has been working for several years. Login worked as it should, i.e. after redirection to Google login, access granted. The user was redirected to the address provided via setRedirectUri
. I have been having a problem for a few weeks because suddenly, after successful login, the user is redirected to myaccount.google.com despite no modifications to the code.
I am attaching a code snippet
$credentials_file = $parameterBag->get('google_credentials');
$client = new Google_Client();
$client->setAuthConfig($credentials_file);
$client->setAccessType("offline");
$client->setIncludeGrantedScopes(true);
$client->setRedirectUri( $this->router->generate('oauth2callback', [], UrlGeneratorInterface::ABSOLUTE_URL) );
$client->setScopes(self::SCOPES);
$client->setPrompt('select_account consent');
$client->setApprovalPrompt('auto');
$code = $request->get('code', null);
if ( !$code ) {
$auth_url = $client->createAuthUrl();
return $this->redirect($auth_url);
} else {
//magic with logged user
}
2
Answers
Have you looked into Google’s side of things?
Check Google Cloud Console :