I'm using the codes from Google documentation. Link
My codes are like this,
$client = new Google_Client();
$client->setApplicationName('Google Calendar API PHP Quickstart');
$client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
$client->setAuthConfig('credentials.json');
$client->setAccessType('offline');
$client->setPrompt('select_account consent');
But when I run this, it's giving an error.
400. That’s an error.
Error: invalid_request
Invalid parameter value for prompt: Invalid prompt: select_account consent/calendar
Please help.
Thanks in advance.
If you check the source code for the libraryclient.php
/**
* Set the prompt hint. Valid values are none, consent and select_account.
* If no value is specified and the user has not previously authorized
* access, then the user is shown a consent screen.
* @param $prompt string
*/
public function setPrompt($prompt)
{
$this->config['prompt'] = $prompt;
}
I dont think you can have both i think you should be setting it to one or the other
$client->setPrompt('consent');
which would imply that there is a bug in the tutorial you are following.
My code
$client = new Google_Client();
$client->setAccessType("offline"); // offline access. Will result in a refresh token
$client->setIncludeGrantedScopes(true); // incremental auth
$client->setAuthConfig(__DIR__ . '/client_secrets.json');
$client->addScope(Google_Service_Calendar::CALENDAR_READONLY);
$client->setRedirectUri(getRedirectUri());
my code Oauth2Authentication.php and oauth2callback.php