【发布时间】:2015-03-01 14:22:38
【问题描述】:
如this SO post 中所述,在开发者控制台中启用 Google 日历 API 后,我可以正常访问它。但是,我在要启用的列表中找不到 Google 日历资源 API。尽管如此,我还是尝试通过 OAuth 2.0 访问资源 API,就像我访问日历 API 一样,但我收到以下错误:
Exception in callback of async function: Error: failed [403]
<HTML> <HEAD> <TITLE>You are not authorized to use this API.</TITLE> </HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>You are not authorized to use this API.</H1>
<H2>Error 403</H2> </BODY> </HTML>
如何让它工作?如果你已经得到它的工作,请分享!
编辑:为了提供更多详细信息,我正在使用 Meteor JS 发布到具有以下标题的以下 URL:
var xmlContent = "<?xml version='1.0' encoding='utf-8'?>" +
"<atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>" +
"<apps:property name='resourceId' value='"+ resource._id +"'/>" +
"<apps:property name='resourceCommonName' value='"+ resource.resourceName +"'/>" +
"<apps:property name='resourceDescription' value='"+ resource.resourceDescription +"'/>" +
"<apps:property name='resourceType' value='"+ resource.resourceType +"'/>" +
"</atom:entry>";
var url = "https://apps-apis.google.com/a/feeds/calendar/resource/2.0/example.com/";
var id = HTTP.post(url, {
'headers' : {
'Content-Type': 'application/atom+xml',
'Authorization': 'OAuth2 oauth_token=' + admin.services.google.accessToken,
'X-JavaScript-User-Agent': "Google APIs Explorer"
},
'content': xmlContent
}
,
function(error, result) {
if (error) throw error;
});//end HTTP.post
【问题讨论】:
-
此 API 仅供 Google Apps 管理员以 Google 数据 API 供稿的形式检索和管理其域的 Google 日历资源。您是该域的管理员吗??
-
是的,我是该域的管理员。
-
您尝试访问的实际资源 URL 是什么?
-
我还没有到访问资源的阶段。我目前只是想创建一个资源。我已经用我的示例代码编辑了我的问题。
标签: meteor google-api google-calendar-api google-oauth google-admin-sdk