我正在创建一个与 Google 日历交互的应用程序并希望观看资源,但我也希望能够停止观看它们。
当我尝试取消观看时,我得到了错误Error calling POST https://www.googleapis.com/calendar/v3/channels/stop: (403) Incorrect OAuth client
我正在使用服务帐户和 OAuth 2.0 对自己进行身份验证,并且绝对可以找到其他有效的 API 调用,因此我知道我已获得授权。我究竟做错了什么?
这些是一些有效的 API 调用......
public function getEvents($calendarId, $opts = array())
{
$events = $this->calendarService->events->listEvents($calendarId, $opts);
return $events;
}
public function getEvent($calendarId, $eventId)
{
$event = $this->calendarService->events->get($calendarId, $eventId);
return $event;
}
public function watch($calendarId, $channelId, $listener)
{
$channel = new Google_Service_Calendar_Channel($this->client);
$channel->setId($channelId);
$channel->setType('web_hook');
$channel->setAddress($listener);
$watchEvent = $this->calendarService->events->watch($calendarId, $channel, array());
return $watchEvent;
}
这是停止 API 调用...
public function stopWatch($channelId, $resourceId)
{
$channel = new Google_Service_Calendar_Channel($this->client);
$channel->setId($channelId);
$channel->setResourceId($resourceId);
$watchEvent = $this->calendarService->channels->stop($channel);
return $watchEvent;
}
关于如何使它工作的任何想法?