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

问题描述

我正在尝试使用Google Calendar API设置应用程序。我设置了所有凭据,并将快速入门指南中所建议的授权JavaScript页面设置为等于 http:// localhost:8000 。当我尝试在 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:

但是,转到提供的链接仅表示我无法访问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日历使用进行授权。这有三个基本要素,如果缺少任何一个,授权将不会正常进行,您将得到一个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 beable to read this file (wherever it may be), otherwise you will haveto manually authorize API calls with every request.
  2. client_secret.json - this is a necessary file to authorize yourapplication itself as a client of google. When you created a clientID and such using the google developer portal, this file wascreated, and must also be read by your application.
  3. Scopes - The scope is what level of access you have. It is bydefault in the quickstart set to "read-only", which could be whyyou're getting 403. If you want to change the scope, you're going tohave to edit both the line of code in the quickstart and eithermodify 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错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 05:39
查看更多