My video on how to use the YouTube Data API v3 to upload videos to your channel from Python scripts and the command line is now on YouTube.
The video walks through how to create a project in the Google API Console, register an application, generate credentials, and use them in a Python script that can be called from the command-line interface to upload videos to your YouTube account with a web browser.
Types of authorization credentials
- OAuth 2.0. The application first sends a client ID and client secret to obtain a token. (This is the method used in the video.)
- API keys. The key identifies your project and provides API access, quota, and reports.
- Service account. Server-to-server, app-level authentication using robot accounts.
Google Account, Project, and Application
- You need a Google Account to access the Google API Console, request an API key, and register your application.
- Create a project in the Google Developers Console and obtain authorization credentials so your application can submit API requests.
- Go to the API Console and select the project that you just registered.
- Visit the Enabled APIs page. In the list of APIs, make sure the status is ON for the YouTube Data API v3.
- Go to the Credentials page and create one.
- Project name
- Organization (optional)
- Your project should now be showing in the dropdown next to Google Cloud Platform.
Create OAuth 2 credentials
Set up a Python environment with the Google API Client Library with Anaconda
conda create -n yt python=3.8 -y && conda activate yt
pip install google-api-python-client
pip install google_auth_oauthlib
python -c "from apiclient.discovery import build;print(build)"
Upgrading the Python upload video script to Python 3
As the upload_video.py sample is written in Python 2, there are minor edits that need to be done to upgrade to Python 3.
from http import client
- Replace appearances of
- Update the syntax of
print statements from Python 2 to 3.
Dispose the created conda environment
You can delete the previously created Python environment when you're done as follows.
conda remove -n yt --all -y
Watch Upload Videos to YouTube with the Data API in Python