我使用資源管理器來測試API並獲得返回數據的感覺。在每個API的右上角有一個「授權使用」開關。這要求我使用我的Google帳戶進行身份驗證。這一切都正確無誤地發生。當我嘗試使用 「data.ga.get」 的方法我得到這個錯誤:Google API資源管理器 - Google Analytics - v3 - 「401未授權」
請求
GET https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A24351574&start-date=2011-01-01&end-date=2012-02-01&metrics=ga%3Apageviews&pp=1&key= {} YOUR_API_KEY
請求
GET https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A24351574&start-date=2011-01-01&end-date=2012-02-01&metrics=ga%3Apageviews&pp=1&key= {} YOUR_API_KEY
Authorization: OAuth ya29.AHES6ZSCqka0X1AVtMrW7iXn7VreLk71vfWB9MrnXCejBYY
X-JavaScript-User-Agent: Google APIs Explorer
Response
403 Forbidden
cache-control: private, max-age=0
content-type: application/json; charset=UTF-8
date: Tue, 28 Feb 2012 01:23:18 GMT
expires: Tue, 28 Feb 2012 01:23:18 GMT
server: GSE
{
"error": {
"errors": [
{
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
奇怪的是auth對於像日曆這樣的API很好。 我不知道我錯過了什麼,會遇到這個問題