Google Calendar API - 403错误 [英] Google Calendar API - 403 error

查看:192
本文介绍了Google Calendar API - 403错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Calendar API设置应用程序。我设置了所有凭据,并将快速入门指南中所建议的授权JavaScript页面设置为等于 http:// localhost:8000 https://developers.google.com/google-apps/calendar/quickstart/js 。当我尝试在 localhost:8000 / quickstart.html 上运行文件时,它将显示基本页面,但没有信息。我可以单击验证按钮,它将允许我验证我的帐户以使用日历应用程序,但没有任何内容将显示信息。检查控制台时,出现以下错误:

I am attempting to set up an application using the Google Calendar API. I set up all the credentials and set the authorized JavaScript page equal to http://localhost:8000 as suggested within the quick start guide at https://developers.google.com/google-apps/calendar/quickstart/js. When I try to run the file on localhost:8000/quickstart.html it will show the basis page but no information. I can click the authenticate button and it will allow me to authenticate my account to use the Calendar application, however nothing will show up information-wise. Checking the console, the following errors are present:


获取 https://content.googleapis.com/calendar /v3/calendars/primary/events?maxResults=10&orderBy=startTime&showDeleted=false&singleEvents=true&timeMin=2017-08-11T20%3A58%3A29.156Z 403()


未捕获{error {errors:[{domain:usageLimits,reason:accessNotConfigured,message:未配置访问日历API尚未在项目440480151645中被使用或禁用。访问 https://console.developers.google.com/apis/api/calendar.googleapis.com/overview?project=44080151645 然后重试如果您最近启用了此API ,等待几分钟,将该动作传播到我们的系统并重试。,extendedHelp: https://console.developers.google.com/apis/api/calendar.googleapis.com /概述项目= 44080151645 }], 码? :403, 消息 : 艾策斯未配置。日历API尚未在项目44080151645中使用或禁用。启用它,访问 https://console.developers.google.com/apis/api/calendar.googleapis.com/overview?project=44080151645 然后重试。如果最近启用了此API,请等待几分钟,将该操作传播到我们的系统并重试。}}

Uncaught {"error":{"errors":[{"domain":"usageLimits","reason":"accessNotConfigured","message":"Access Not Configured. Calendar API has not been used in project 440480151645 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/calendar.googleapis.com/overview?project=44080151645 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.","extendedHelp":"https://console.developers.google.com/apis/api/calendar.googleapis.com/overview?project=44080151645"}],"code":403,"message":"Access Not Configured. Calendar API has not been used in project 44080151645 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/calendar.googleapis.com/overview?project=44080151645 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."}}

但是,转到提供的链接仅表示我无法访问calendar.googleapis.com api,不会让我启用我的Google日历或使用它。

However, going to the supplied link only says that I do not have access to the calendar.googleapis.com api and will not let me enable my Google Calendar or use it.

推荐答案

Google日历使用 Oauth2.0 进行授权。这有三个基本要素,如果缺少任何一个,授权将不会正常进行,您将得到一个403.

Google calendar uses Oauth2.0 for authorization. There are three essential components of this. If any of these are missing, authorization will not happen properly and you'll get a 403.


  1. 访问令牌 - 默认情况下,Google日历API将访问令牌保存到
    /.credentials文件夹中。您的应用程序将需要
    才能读取此文件(无论它在哪里),否则您将
    每个请求手动授权API调用。

  2. client_secret.json - 这是一个必需的y文件授权您的
    应用程序本身作为Google的客户端。当您创建一个clientID并且使用谷歌开发者门户网站时,该文件是
    创建的,并且还必须由您的应用程序读取。

  3. 范围 - 范围是什么级别访问你有在
    默认设置为只读,这可能是为什么
    你得到403.如果你想改变范围,你将要
    必须在快速启动中编辑 代码行,并且
    修改访问令牌或获取一个新的代码以反映该更改。

  1. Access token - the google calendar API saves an access token to your /.credentials folder by default. Your application will need to be able to read this file (wherever it may be), otherwise you will have to manually authorize API calls with every request.
  2. client_secret.json - this is a necessary file to authorize your application itself as a client of google. When you created a clientID and such using the google developer portal, this file was created, and must also be read by your application.
  3. Scopes - The scope is what level of access you have. It is by default in the quickstart set to "read-only", which could be why you're getting 403. If you want to change the scope, you're going to have to edit both the line of code in the quickstart and either modify the access token or get a new one to reflect that change.

之前我已经收到这个错误,但是在我理解Oauth2之前。如果问题不在这些中,可能是您在开发者控制台中选择的。让我知道,如果你仍然卡住。

I have gotten this error before, but that was before I understood Oauth2. If the problem isn't in any of these, it's likely something that you selected in the developer console. Let me know if you are still stuck.

这篇关于Google Calendar API - 403错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆