使用oauth2调用youtube Data API端点时获取403

时间:2019-09-02 11:53:01

标签: curl google-api youtube-api

我正在测试YouTube数据API,以允许我们的用户使用oauth2将一些视频上传到他们的youtube帐户。

我正在尝试使用curl调用https://www.googleapis.com/youtube/v3/videos端点

我尝试使用空白引荐来源网址,但现在尝试使用受限制的IP,但仍然收到403:

https://i.postimg.cc/mZy14Dsm/stackoverflow-youtube-api-1.png

enter image description here

您可以看到该API似乎已启用:

enter image description here

curl --request POST \
 'https://www.googleapis.com/youtube/v3/videos?part=snippet%2Cstatus&key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
 --header 'Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
 --header 'Accept: application/json' \
 --header 'Content-Type: application/json' \
 --data '{"snippet":{"categoryId":"22","description":"Description of uploaded video.","title":"Test video upload."},"status":{"privacyStatus":"private"}}' \
 --compressed

我得到以下输出:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. YouTube Data API has not been used in project XXXXXXXXXX before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=XXX then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "extendedHelp": "https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=XXX"
   }
  ],
  "code": 403,
  "message": "Access Not Configured. YouTube Data API has not been used in project XXX before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=XXX then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
 }

用户的access_token似乎正在工作,因为我没有收到401。 我是否使用了正确的钥匙,我开始对此表示怀疑? 我在这里不明白什么? 非常感谢。

0 个答案:

没有答案