dongtang6718 2016-06-01 23:03
浏览 20
已采纳

Youtube Content ID API总是返回Not Found

My account is connected to a CMS but I can't see Youtube Content ID in API Library. However, I see it in my Enabled APIs!! (It appeared after I try "Authorize requests using OAuth 2.0" in Youtube Content ID API reference doc). I can test the API in reference doc and it shows data from my CMS. But when I call the API from my program, the response is always like this:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Not Found"
   }
  ],
  "code": 404,
  "message": "Not Found"
 }
}

This is my implementation using Go:

func TestYoutubeAPI(w http.ResponseWriter, r *http.Request)  {
    data, err := ioutil.ReadFile("./google-service-key.json")
    if err != nil {
        log.Fatal(err)
    }
    config, err := google.JWTConfigFromJSON(data, "https://www.googleapis.com/auth/youtubepartner", "https://www.googleapis.com/auth/youtube.force-ssl", "https://www.googleapis.com/auth/youtube")
    if err != nil {
        log.Fatal(err)
    }
    client := config.Client(oauth2.NoContext)

    request, _ := http.NewRequest("GET", "https://www.googleapis.com/youtube/partner/v1/assetSearch", nil)
    request.Header.Add("Accept", "application/json")

    query := request.URL.Query()
    query.Add("createdAfter","2015-01-29T23:00:00Z")
    query.Add("key", "XXX")
    request.URL.RawQuery = query.Encode()

    response, err := client.Do(request)

    if err != nil {
        fmt.Fprintln(w, err)
    } else {
        responseBody, _ := ioutil.ReadAll(response.Body)
        fmt.Println(response.Status)
        fmt.Fprintln(w, string(responseBody))
    }
}

Other APIs (Youtube Data API) work fine with this code. However, I can't get my expected result with Youtube Content ID API.

Anyone got experience in this please help me. Thank you.

  • 写回答

1条回答 默认 最新

  • dongqu1783 2016-06-02 09:32
    关注

    I found the answer!

    Because I used Google Service Account to interact with Google API. It seems to create a new user account. So that I have to grant permission on Youtube CMS by adding Service account client email to Youtube CMS. Finally, I can access Youtube CMS using the API.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器