1

I have looked around Stack Overflow and seen a few posts about this but none of the solutions help.

I have a Google account which I use in YouTube. I have created a second channel on that YouTube account so that I can upload videos with a specific theme to separate them from the main videos.

Trying to use the Google API to upload the videos so that I can run it via a Python script, I keep hitting brick walls with Google who is looking for app verification, privacy policies and web page links - none of which I have.

This application is a Python script that's not available to the public and doesn't gather any public information. All I am trying to do is upload videos to my own personal YouTube account.

So I'm beginning to think it is something else I should be using rather than the API (the uploading web page isn't suitable for use in a script).

My two question are:

  1. Can I use the YouTube API to upload a video directly to the second channel on my personal YouTube account?

  2. Is there another simpler mechanism I should be using to upload videos via a script to my personal YouTube account? The reason I have to do it via script is that the device is unattended.

Thanks,

David

stvar
  • 6,551
  • 2
  • 13
  • 28
David
  • 11
  • 2

1 Answers1

0

You have to acknowledge that each and every app (this to be understood in a broad sense that includes even a small script like this one from Google upload_video.py) must be verified and approved by Google prior to be able to make videos publicly available via the YouTube site.


Answer to question no. 1: yes, that is perfectly possible.

As part of the OAuth 2.0 authentication/authorization flow, you will be presented, within the browser, with the option of selecting to which account your app is to be given access rights.

You may well exercise this behavior, prior to making use of your script, with the help of Google Developers OAuth 2.0 Playground.

Upon a successful OAuth flow, you may verify (and also revoke) the permissions granted by your account on the account's permissions page.

Answer to question no. 2: no, there's no way to upload programmatically videos on YouTube that's in compliance with YouTube's DTOS, other than using the Videos.insert API endpoint.

Addendum

Since by now you have at least two credentials sets, it may be of need to know to which of your YouTube channels a given credentials object is associated.

If using the Google APIs Client Library for Python, you may easily obtain from the API the channel ID to which a given credentials object CREDENTIALS is associated by issuing a call to the Channels.list API endpoint, passing to it the parameter mine as mine=true:

from googleapiclient.discovery import build

youtube = build(
    'youtube', 'v3',
     credentials = CREDENTIALS)

response = youtube.channels().list(
    mine = 'true',
    part = 'id',
    fields = 'items(id)',
    maxResults = 1
).execute()

channel_id = response['items'][0]['id']

Note that the code above uses the fields request parameter for to obtain from the Channels.list endpoint only the channel's ID info (it is always good to ask from the API only the info that is of actual use).

A caveat using the above procedure is the following: if a given CREDENTIALS instance has its scopes containing only:

https://www.googleapis.com/auth/youtube.upload,

then the API will respond with an error of type insufficientPermissions and of message Request had insufficient authentication scopes.

For to invoke successfully the Channels.list it would be sufficient that the scopes attached to CREDENTIALS to include either of the one below:

https://www.googleapis.com/auth/youtube.readonly, https://www.googleapis.com/auth/youtube.

stvar
  • 6,551
  • 2
  • 13
  • 28
  • Thank you for your reply, I acknowledge that something like that has to take place but what I dont understand is having to provide a privacy policy and website end point for a private script. This seems like a box ticking exercise. But maybe I don't understand it fully as I'm new to the API world. Could you advise how I go about uploading a video to the second channel on my account as I'm really starting to struggle with this so your help would be greatly appreciated. I have the API upload to my primary channel functioning correctly. – David Oct 26 '20 at 18:17
  • There's nothing special about uploading to a secondary YouTube channel attached to the same Google account. This has been [already answered here on SO](https://stackoverflow.com/a/63672423/8327971). I'll update my answer above. – stvar Oct 26 '20 at 18:25
  • I would suggest to answer with `N/A` to those questions that are not applicable to your app's use case. – stvar Oct 26 '20 at 18:54
  • Thank you all for the help. Unfortunately I am hitting a 401 error ""youtubeSignupRequired" when I try to use the API now. I have read what this error means here: https://developers.google.com/youtube/v3/docs/errors which states my google account doesn't have a channel. I don't understand this error as I do have a channel (2 in fact). Can anyone advise how I get by this? – David Oct 27 '20 at 08:44
  • Have you tried to use the OAuth playground? That's what I suggested. If things worked in the playground, then, prior to run your script on the same machine and local user account, make sure you rename and/or move the local file than stores your credentials (refresh token and such), such that your script starts afresh, i.e. it starts a new OAuth authorization/authentication flow. – stvar Oct 27 '20 at 11:08
  • Thanks, I've now gone back and tried the OAuth playground. I'm getting "error": "reason": "quotaExceeded", "message": "The request cannot be completed because you have exceeded your quota.", "domain": "youtube.quota" } ] } }. Guess I'll need to wait until tomorrow for my next 6 chances of uploading videos before I hit my quota. I will report back after I've tried it. Thanks again for all your advice, it's appreciated – David Oct 27 '20 at 15:12
  • Thank you stvar! I have accessed the playground and got it working now. I hadn't clicked on my second channel when I gave permission. My fault. I'm still limited to 6 uploads per day (10000 units) but that's something I'll probably need to raise with Google to see if they are willing to increase it. Thanks again for your help. – David Oct 28 '20 at 09:35
  • See my updated answer above for relevant additional info. – stvar Oct 28 '20 at 10:13
  • @David are u now able to upload video with private script? Did you need to go through verification process? – cikatomo Dec 05 '20 at 20:53
  • @cikatomo: The verification process is required; no way to avoid it. See [my answer](https://stackoverflow.com/a/64080239/8327971) for the official Google staff's accounts quoted therein. – stvar Dec 05 '20 at 20:58
  • @stvar ok thank you, did you approve yours? Is it hard? – cikatomo Dec 05 '20 at 21:09
  • @cikatomo: I didn't have to do it, yet. But according to the experience of other SO users, upon filling in the [official form](https://support.google.com/youtube/contact/yt_api_form?hl=en), unfortunately, the answer does not come shortly. – stvar Dec 05 '20 at 21:18
  • @stvar I just found out it only matters for project created after 28 July, so for projects created before that no need to verify yet – cikatomo Dec 05 '20 at 21:32
  • 1
    @cikatomo: Indeed, the official doc of [`Videos.insert`](https://developers.google.com/youtube/v3/docs/videos/insert) API endpoint states exactly that. – stvar Dec 05 '20 at 21:38