2012-07-16 138 views
0

有人可以告诉我为什么我无法使用相同的令牌从Google检索userInfo和日历列表吗?OAuth令牌适用于userInfo,但不适用于Google日历

我已经设置了正确的范围(我认为):

​​

为了让我使用这个网址的用户信息:https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=和日历使用:https://www.googleapis.com/calendar/v3/users/me/calendarList?minAccessRole=writer&key=

在用户信息中,我得到所有正确的信息,但对于我收到的日历错误401:需要登录。

这里有什么问题?

回答

1

变化

https://www.googleapis.com/calendar/v3/users/me/calendarList?minAccessRole=writer&key=

https://www.googleapis.com/calendar/v3/users/me/calendarList?minAccessRole=writer&access_token=

就这么简单;)

UPDATE:

还要注意,它不推荐指定access token as a query parameter

由于与URI方法相关联的安全漏洞的(见第5章),包括高可能会记录包含访问令牌的URL,除非无法在“Authorization”请求头字段或HTTP请求实体主体中传输访问令牌,否则不应使用它。

+0

感谢您的答案1月和德建议。 – 2012-07-16 17:32:28

+0

不客气:) – 2012-07-16 17:41:05

+0

所以我可以进行相同的调用,并在标头中传递令牌(而不是查询参数)?像这样的https://www.googleapis.com/calendar/v3/users/me/calendarList?minAccessRole=writer(和标题中的标记)?谢谢 – OhadR 2012-11-09 17:56:35

相关问题