【发布时间】:2013-09-11 20:03:06
【问题描述】:
我正在使用 nodejs,我想显示一些来自谷歌分析的数据。
在 google API explorer 上,我找到了这个 url 来获取我的数据:
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%XXXXX&start-date=2013-08-17&end-date=2013-09-15&metrics=ga%3Avisits&key={YOUR_API_KEY}
但是,如果我访问此网址,我会得到:
{"error":{"errors":[{"domain":"global","reason":"required","message":"Login Required","locationType":"header","location":"Authorization"}],"code":401,"message":"Login Required"}}
如何通过 url 传递我的登录信息,然后访问我的数据?
谢谢!
【问题讨论】:
-
你真的把你的 API 密钥放在这里了吗?
&key={YOUR_API_KEY} -
是的,我做到了。但似乎我需要令牌。我使用请求调用
https://www.googleapis.com/analytics/v3/data/ga?ids=ga:XXXXX88&metrics=ga:visits&start-date=2013-08-17&end-date=2013-09-15&access_token=XXXXXXXX&access_type_token=bearer,一切正常。 -
但是当我尝试刷新令牌时,使用
https://accounts.google.com/o/oauth2/token?client_secret=XXX&grant_type=refresh_token&refresh_token=YYYY&client_id=ZZZZ上的请求我得到error, invalid request.
标签: node.js google-analytics google-api