错误:“消息":“需要登录"何时使用 Youtube Analytics API [英] Error: "message": "Login Required" when use Youtube Analytics API
问题描述
我正在使用 youtube api.当我点击这个网址时https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=2015-01-01&end-date=2016-01-31&metrics=likes%2Cdislikes&key={API Key}"
I am working with youtube api. when I hit this url "https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=2015-01-01&end-date=2016-01-31&metrics=likes%2Cdislikes&key={API Key}"
它给出了 401
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
但我在浏览器中点击了https://developers.google.com/apis-explorer/?"它工作正常.
如何使第一个请求有效?
but I hited in the explorer "https://developers.google.com/apis-explorer/?"
it working fine.
How do I make the first request work?
推荐答案
在您的请求中,您正在发送 key={your key} 以获得访问令牌,您应该发送 access_token={your oauth2 access token}
In your request you are sending key={your key} for an access token you should be sending access_token={your oauth2 access token}
注意:密钥用于公开请求.访问令牌用于经过身份验证的请求.
Note: Key is used for public requests. access token is for authenticated requests.
这篇关于错误:“消息":“需要登录"何时使用 Youtube Analytics API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!