YouTube Data API v3 を用いて非公開ビデオの情報を取得するためのポイント

前提

OAuth での認証は終えているものとします。

結論

forMinetrue に指定し、かつ、channelId指定しない

説明

forMinetrue にすればいいことは ドキュメント を読めば分かると思います。しかし、その際に channelId を、例え自分のものであれ設定すると下記のようなエラーになります。Ruby 実装での例です。

invalidSearchFilter: The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set either the <code>forContentOwner</code> or <code>forMine</code> parameters to <code>true</code>. You must also set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters. (Google::Apis::ClientError)

つまり、特定のオプションの組み合わせだとエラーになるということです。そしてその組み合わせに該当しているということです。

補足

そして当たり前のことですが、非公開ビデオを見られるアカウントで認証をしたクライアントのオブジェクトにおいて、上記操作を行う必要があります。

私はもろもろあって、ちょっとハマってしまいました。

Powered by はてなブログ