osapi.people.get()在Google日历侧边栏小工具中返回404

时间:2015-11-19 17:42:41

标签: google-calendar-api google-oauth2 google-gadget opensocial

对于带有模块首选项的html类型日历侧边栏小工具,

<Require feature="opensocial-0.9"/>
<Require feature="osapi" />

对osapi.http的调用都成功发送,这导致404响应:

osapi.people.get({userId:'@viewer'}).execute(function(response) {
    console.log(response);
});

这包含在POST中,与osapi.http调用的RPC终端相同,post对象符合预期:

[{"method":"people.get","id":"people.get","params":{"userId":"@viewer","groupId":"@self"}}]

当小工具需要opensocial-0.8或opensocial-0.9时,与osapi.http或osapi.people的行为没有区别。我认为这次调用不需要身份验证令牌 - 这是真的吗?谷歌日历是否支持osapi.people?

1 个答案:

答案 0 :(得分:0)

我改为使用JS API Client Library并按照Authentication using the Google APIs Client Library for JavaScript中的顺序进行操作。您的范围可以包含显式网址或声明,例如“openid”(请参阅​​OpenID Connect explained)。这将导致

GET https://accounts.google.com/o/oauth2/auth?client_id=...

其中请求参数“origin”的网址(例如:https://....opensocial.googleusercontent.com)必须是Google Developers Console中客户的授权Javascript来源。

返回的authResult应包含access_token。如果没有,那么authResult.error_subtype的可能原因......

  • 'origin_mismatch':原产地不属于授权来源
  • 'access_denied':范围不包含身份网址或'openid'