Search code examples
httpgoogle-apiyoutube-apigoogle-oauth

Can I upload a youtube video using the youtube api without a gui?


I am trying to automate video upload to YouTube without me needing to click a web-browser to authorize the upload every time.

enter image description here

When I go to the Youtube API console to setup some credentials, presumably with "User Data" because I assume that is what you need to upload, it gives the following warning:

enter image description here

Does this mean that there is no way to automate uploading videos from a console application, and that every upload will require me to click from a browser?


Solution

  • The first screen you are looking at is the Oauth2 authorization screen. In order to access private user data you must have access to that data. Oauth2 gives you that option by asking the user can I access your data?

    The fact that you want to upload to data you own would normally lead me to say you should use a service account. Service accounts are preauthorized. I could take the service account email address and grant it access to a folder on my google drive and then it would be able to read and write from that folder.

    This is not an option with YouTube. The YouTube api does not support service accounts.

    You will need to authenticate your code yourself once save the refresh token then use that in your console application to request an new access token and upload the video.

    Answer: With the YouTube API there is no way around the authorization form you have to authenticate it.