I work for a school that has an institutional YouTube account (Google Apps for Education). The video privacy options are Public, Unlisted, and Private.
The important bit: Private videos can be shared with either: - the institution (i.e., all students with a school account), or - a list of specific email addresses.
We have a tool that uses the v3 YouTube API (Java) to automatically upload videos to YouTube.
I can use the API to set privacy:
VideoStatus videoStatus = new VideoStatus();
videoStatus.setPrivacyStatus("private");
But how do I set sharing (e.g., "Shared with school.edu") using the YouTube API? I assume it's possible because it can be done (manually) using YouTube's online Video Manager.
It seems more people are being left in the dark about this, but most questions date from some years ago.
E.g.: YouTube API: Private Video Access which links to a YT dev reaction: https://groups.google.com/forum/#!topic/youtube-api-gdata/LkfDtwxjWp8/discussion (May 2012)
There is not, unfortunately, and I don't believe that specific functionality will be added.
Moreover the bug JAL linked to dates from April 2014, so it seems like private video's come with their own set of problems.
To conclude, I'll be sticking to the unlisted video approach, which seems like a good trade-off for me. I can return the unlisted video's for my own set of users, which gives me control on that level. If some user feels like mailing around the YouTube link, that's just too bad. As the aforementioned link states:
Sometimes, security is about compromise. At one end of the spectrum, you can lock things down completely so that no one can access the data. At the other end, the most usable and accessible data will not be secure.
After reviewing the YouTube Data API v3 documentation, I have come to the conclusion that this is not possible with the current API.
This may be related to Issue 6265 that is currently reported as an API defect. If this does not address your use case I strongly suggest you file an enhancement ticket to gdata-issues.
来源:https://stackoverflow.com/questions/37579534/how-can-i-set-videos-to-private-yet-shared-using-the-v3-youtube-api