2012-07-16 139 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

相關問題