错误 400:Google 日历 API PHP 的提示无效
Error 400: Invalid prompt for Google Calendar API PHP
我正在使用 Google 文档中的代码。 Link
我的代码是这样的,
$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');
但是当我运行这个的时候,它给出了一个错误。
400. That’s an error.
Error: invalid_request
Invalid parameter value for prompt: Invalid prompt: select_account consent/calendar
请帮忙。
提前致谢。
如果您检查库的源代码client.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;
}
我认为你不能同时拥有两者,我认为你应该将其设置为其中之一
$client->setPrompt('consent');
这意味着您正在学习的教程中存在错误。
我的代码
$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());
我正在使用 Google 文档中的代码。 Link
我的代码是这样的,
$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');
但是当我运行这个的时候,它给出了一个错误。
400. That’s an error.
Error: invalid_request
Invalid parameter value for prompt: Invalid prompt: select_account consent/calendar
请帮忙。
提前致谢。
如果您检查库的源代码client.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;
}
我认为你不能同时拥有两者,我认为你应该将其设置为其中之一
$client->setPrompt('consent');
这意味着您正在学习的教程中存在错误。
我的代码
$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());