How to set up Youtube API
Requirements
- Python 3 or higher
- Install the Google APIs Client Library for Python Register your application with Google so that it can use the OAuth 2.0 protocol to authorize access to user data.
Open https://console.developers.google.com/apis/credentials. Then create a new External OAuth Consent Screen. Leave the App domain and the Authorized domains blank. Then click next
and next. At the testing page add your email. Then click go to dashboard Go to the credentials page again. Then create a new OAuth 2.0 Client ID Add your url in the Authorized redirect URIs.
Do not miss a slash or https because that will cause an error. Then create it.
Copy the client_id and client_secret - You will need them both later.
Setup code
To use OAuth 2.0 steps with this script, you'll need to create a client_secrets.json file that contains information from the API Console. The file should be in the same directory as the script.
{ "web": { "client_id": "[[INSERT CLIENT ID HERE]]", "client_secret": "[[INSERT CLIENT SECRET HERE]]", "redirect_uris": [], "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token" } }
Rename the file to upload_video.py-oauth2.json.
Open the link in a new tab and copy and paste the code to a file called upload_video.py and save it.
Then run it
Happy Coding!!!