Please wait while loading...
Back Google Oauth 2.0 ask permission every time

I have made a application using google account for login. Reference to google's example, it's easy make the login work well. However, I'm face to a serious problem that google ask for permission approval every time. For a openid login, like facebook, we will ask permission in the first time only and for the next time, it should automatically complete the login and no need to approve by user again. For this purpose, I search from the internet and finally found the solution as following:

To make the application just ask permission for once, add the following line in the config


Example for a full code:

require_once 'src/contrib/Google_Oauth2Service.php';
$client = new Google_Client();
if ($client->getAccessToken()) {
  //alwaydy login redirect to user account
} else {
  $authUrl = $client->createAuthUrl();
comments powered by Disqus