【问题标题】:Google calendar v3 returns 403 Insufficient Permission谷歌日历 v3 返回 403 权限不足
【发布时间】:2018-03-27 16:00:51
【问题描述】:

我一直在尝试使用服务帐户访问 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"}}

我错过了什么吗?

【问题讨论】:

    标签: ruby-on-rails google-api google-calendar-api http-status-code-403 google-api-client


    【解决方案1】:

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

    【讨论】:

    • @erjoalgo 你用过 Ruby 和 Ruby on Rails 吗?我问这个问题是因为正如我从 SO 标签中看到的那样,您是在 Python 上编写的。
    【解决方案2】:

    您对此感到高兴吗?我碰到了同样的砖墙。

    更新:

    $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
    );
    

    在与服务电子邮件帐户共享日历后,这对我的授权有效。

    【讨论】:

    • 您是指您用于服务的整个 Google 帐户吗?是否可以调用 listCalendarList 之类的东西,还是只能对特定日历进行操作?
    • 我现在可以做各种 Google_Service_Calendar_Event 的事情了,你是不是被什么困住了?
    • 我无法让服务帐户工作。我可以进行基本通话,但如果不在 Google Apps 域中,它似乎受到限制。改用 OAuth,这对我们的应用程序来说不太方便,但调用确实有效。
    【解决方案3】:

    我认为如果您使用 Google Calendar Quickstart for Ruby,我认为您应该删除指定路径中的凭据...我试了一下,效果很好...您可以在此处查看凭据的放置位置

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

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

    【讨论】:

      【解决方案4】:

      首先改变

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

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

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

      然后再次运行。

      这对我有用!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-09-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-27
        • 2018-06-13
        • 2021-12-02
        • 1970-01-01
        相关资源
        最近更新 更多