After adding scope "https://www.googleapis.com/auth/calendar.readonly" causing the below error.
$gClient = new Google_Client();
$gClient->setApplicationName('Login');
$gClient->setClientId($google_client_id);
$gClient->setClientSecret($google_client_secret);
$gClient->setRedirectUri($google_redirect_url);
$gClient->setScopes(array('https://www.googleapis.com/auth/calendar.readonly'));
Error received is
Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/oauth2/v2/userinfo: (401) Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.' in C:\xampp\htdocs\bvs\online-payment\src\io\Google_REST.php:66 Stack trace: #0 C:\xampp\htdocs\bvs\online-payment\src\io\Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1 C:\xampp\htdocs\bvs\online-payment\src\service\Google_ServiceResource.php(177): Google_REST::execute(Object(Google_HttpRequest)) #2 C:\xampp\htdocs\bvs\online-payment\src\contrib\Google_Oauth2Service.php(37): Google_ServiceResource->__call('get', Array) #3 C:\xampp\htdocs\bvs\online-payment\login.php(49): Google_UserinfoServiceResource->get() #4 {main} thrown in C:\xampp\htdocs\bvs\online-payment\src\io\Google_REST.php on line 66