TWA Blog.

How to set up Youtube API

Cover Image for How to set up Youtube API
Tech With Anirudh
Tech With Anirudh

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.


A Pen by Anirudh (codepen.io)

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!!!


More Stories

Cover Image for I am Asia's youngest Microsoft Power Platform Certified

I am Asia's youngest Microsoft Power Platform Certified

I am Asia's youngest Microsoft Power Platform AI Certified.

Tech With Anirudh
Tech With Anirudh
Cover Image for I am the world's youngest Microsoft Azure AI Certified

I am the world's youngest Microsoft Azure AI Certified

I am the world's youngest Microsoft Azure AI Certified.

Tech With Anirudh
Tech With Anirudh