首页 文章

Google日历v3会返回403不足的权限

提问于
浏览
6

我一直在尝试使用服务帐户访问Calendar v3 API . 我已经从管理控制台添加了范围https://www.googleapis.com/auth/calendar,并将该日历与该服务帐户的电子邮件地址共享 .

我也一直使用相同的服务帐户访问https://www.googleapis.com/auth/coordinate范围,它工作正常 .

此外,尝试撤销访问权限如下所述:Why is Google Calendar API (oauth2) responding with 'Insufficient Permission'?

所有这一切,我仍然得到;

{"error"=>
  {"errors"=>
    [{"domain"=>"global",
      "reason"=>"insufficientPermissions",
      "message"=>"Insufficient Permission"}],
   "code"=>403,
   "message"=>"Insufficient Permission"}}

我错过了什么吗?

4 回答

  • 4

    尝试添加范围'userinfo.email'并在开发人员控制台“Contacts API”和“Google API”中启用 . 我花了两周时间寻找这个问题的答案,这个技巧对我有用 .

  • 0

    你对此有什么喜悦吗?我碰到了同样的砖墙 .

    更新:

    $key = file_get_contents($key_file_location);
    $scopes = array('https://www.googleapis.com/auth/calendar');
    $cred = new Google_Auth_AssertionCredentials(
        $service_account_name,
        $scopes,
        $key
    );
    

    在与服务电子邮件帐户共享日历后,这适用于我的授权 .

  • 0

    我想如果您使用Google Calendar Quickstart for Ruby,我认为您应该删除指定路径中的凭据...我尝试它并且运行良好...您可以在此处查看凭据的放置位置

    CREDENTIALS_PATH = File.join(Dir.home, '.credentials',
                                 "calendar-ruby-quickstart.yaml")
    

    在您的家庭目录中,您可能会在批准Google访问您的数据请求后找到Google存储您的凭据的目录 .

  • 0

    首先是改变

    static string[] Scopes = { CalendarService.Scope.CalendarReadonly };
    

    static string[] Scopes = { CalendarService.Scope.Calendar };
    

    然后在你的文件夹中删除 .credentials 文件夹

    并再次运行 .

    这对我有用!

相关问题