Google API日历403 InsufficientPermissions错误

时间:2017-04-05 15:29:26

标签: php xampp google-calendar-api

早些时候我发送了一些请求来获取日历列表,它运行正常。但是当我想用另一个范围(Google_Service_Calendar :: CALENDAR)创建一个辅助日历时,它会触发403 403Persmission错误。

这是代码

<?php
   require_once 'vendor/autoload.php';
   session_start();

   $client = new Google_Client();
   $client->setAuthConfig('client-secret.json');
   $client->addScope(Google_Service_Calendar::CALENDAR);
   if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
         $client->setAccessToken($_SESSION['access_token']);
         $service= new Google_Service_Calendar($client);
         $calendar = new Google_Service_Calendar_Calendar();
         $calendar->setSummary('CalendarioProper');
         $calendar->setTimeZone('Europe/Madrid');

         $createdCalendar = $service->calendars->insert($calendar);

         echo $createdCalendar->getId();

     } else {
         $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] .'/oauth2callback.php';
         header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
     }
   ?>

这是我执行文件

后得到的错误
Uncaught Google_Service_Exception: { 
"error": 
    { "errors": [ { 
            "domain": "global", 
            "reason": "insufficientPermissions",
            "message": "Insufficient Permission" } ], 
      "code": 403, 
      "message": "Insufficient Permission" } }

P.D:我通过XAMPP的本地主机做了一切,也许这会对我的问题做些什么?

0 个答案:

没有答案