我正在制作一个同步谷歌日历活动的应用程序 .

我的问题是更新谷歌事件,当我尝试这样做时,我得到403 Forbidden错误,没有其他细节 . 最奇怪的是,我可以获取事件,创建它们,但不更新它们 . 我知道用户无法编辑事件的可能性,但在这种情况下,用户是日历的所有者,因此不应该应用 . 我正在使用谷歌api v3的PHP .

实际错误:调用PUT https://www.googleapis.com/calendar/v3/calendars/primary/events/_eventId时出错:(403)禁止

我已经尝试将日历分享到谷歌控制台中的电子邮件地址,这没有帮助,也尝试在离线模式下不使用令牌进行更新,但没有成功 .

欢迎任何帮助或建议,我花了太多时间研究这个没有解决方案,所以我现在没有想法 .

编辑:使用的代码:

//For the client we use the token with refresh token
        $googleAccount = $this->getGoogleAccountRepository()->findOneBy(['user' => $user]);
        $client = $this->getClient($user, $googleAccount,$group);
        $service = new Google_Service_Calendar($client);
        $calendarId = "primary";
        // First retrieve the event from the API.
        $eventRetrieved = $service->events->get($calendarId, _eventId);
        $event = new Google_Service_Calendar_Event($eventRetrieved);
        $event->setSummary(_newSummary);
        $event->setDescription(_newDescription);
        $start = new \Google_Service_Calendar_EventDateTime();
        $start->setDateTime(_someDatetime->format(\DateTime::RFC3339));
        $end = new \Google_Service_Calendar_EventDateTime();
        $end->setDateTime(_someDatetime->format(\DateTime::RFC3339));
        $event->setStart($start);
        $event->setEnd($end);
        $event->setLocation(_newLocation);
        try{
            $updatedEvent = $service->events->update($calendarId, $eventRetrieved->getId(), $event);
        }
        catch(\Google_Exception $ex)
        {
            return;
        }