错误400:Google Calendar API PHP的无效提示

时间:2018-12-03 10:15:30

标签: php google-api google-calendar-api google-api-php-client

我正在使用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

请帮助。
预先感谢。

1 个答案:

答案 0 :(得分:1)

如果您检查库的源代码client.php

this.adultPaxIdx = -1;

我认为您不能同时拥有两者,我认为您应该将其设置为另一个

   /**
   * 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');

我的代码Oauth2Authentication.phpoauth2callback.php