VL.Youtube

Some examples how to use the Youtube Data API (v3) in VL.

Words auf caution:

  • I don’t really know what I am doing
  • This is rather a doodle than a real WIP
  • It was created over the course of several month, the structure isn’t very consistent
  • It’s only superficially tested
  • The API has lots of parameters the ones I used were chosen arbitrarily
  • There is no error/exception handling (for now)

You can get it here:

Open the definitions patch to get an overview of the available examples. (Alt+Shift+A)


Getting Started

1. You’ll need a google account:
https://www.google.com/accounts/NewAccount

2. If you have an account log in, go to youtube and create a channel
https://www.youtube.com/channel/

3. Create a project in the Google developer console
https://console.developers.google.com

image

...

image

4. Obtain authentication credentials for the project you’ve created
https://console.developers.google.com/projectselector/apis/credentials

4.1 Go to OAuth consent screen, set an Application Name and save

4.2 Select ApiKey from Create Credentials

image

4.3 Select OAuth client ID from Create Credentials

image

  • Choose Web application
  • Set a name
  • Add OAuth 2.0 Playground to Authorized redirect URIs (needed in next step)

image

5. Normally there is a “3-legged OAuth flow” that needs to be implemented by applications for authentication. But it’s also possible to authenticate using a long-lived so called refresh token.
To obtain such a token go to:

5.1 Click on Oauth 2.0 Configuration

5.2 Activate Use your own OAuthcredentials

5.3 Enter your OAuth Client ID and OAuth Client Secret

0%20Playground

5.4 On the left hand side select the APIs you want to authorize and click the Authorize APIs button

image

5.5 Maybe you’ll have to sign in or select your google account

5.6 Most likely you will then be greeted by a warning, click on Advanced and then Go to YourProjectName (unsafe)

image

5.7 Now grant the permissions

image

Confirm

5.8 Back on the Playground Click on Exchange authorization code for tokens Button

5.9 Copy the Refresh Token and keep it somewhere safe

Token

6. You can now use OAuth Client ID , OAuth Client Secret and Refresh Token in VL.Youtube for authentication

7. For “simple” requests like searches you can also use the API key

See also:

Last but not least:
Youtube assigns a quota to each user/application currently it’s 10.000. Every request has a certain quota cost. Most operations are “cheap”, uploading a video though currently has a quota cost of at least 1.600, so one is limited to about 6 videos per 24h - it doesn’t matter how short/small videos are.
You can try to have your quota raised but it’s a rather lenghty process and it’s not certain if a higher quota will be granted and when.
https://services.google.com/fb/forms/ytapiquotarequest/

Thanks to @tonfilm for:

6 Likes

FYI

Hi YouTube Developer,

We’re writing to let you know about upcoming changes to the YouTube API Services that will affect API projects created after July 28, 2020 .

All videos uploaded via the videos.insert endpoint from unverified API Projects created after this date will be restricted to private viewing mode. To lift this restriction, each project must undergo an audit to verify compliance with the Terms of Service.

Creators who use an affected project to upload video will receive an email explaining that their video is locked as private, and that they can avoid the restriction by using an official or audited service.

Existing API projects will not be affected by this change, but we strongly recommend that all developers complete a compliance audit for their projects to ensure continued access to the YouTube API Services.

Thanks,
YouTube API Services Team