3

For the context: I am building a React App that allows users to upload an MP3 file and an image. Both these files get rendered to an MP4 file through FFmpeg on the client side (in React). I then want to let the user upload the result to YouTube.

So technically everything executed on the YouTube API comes from the user and isn't made through any server. How would I go about uploading the video without having an API Key, just having an OAuth 2.0 object from the user that signed in and that wants to upload the processed video to their channel?

The main problem is that generally a YouTube user has a quota of 50 uploads per day that can be made use of but if I follow YouTube's docs I'd have to upload the videos through a Google Cloud Project Client (which gives me an API Key) and said client would have a predefined quota for all requests (which is about 2 videos per day). Now that's not what I want, through using a client my entire app would only have 2 uploads per day and not 50 uploads per day per user.

Does anyone have experience with such a problem or an idea on how I could work this out?

1

1 Answer 1

2

How would I go about uploading the video without having an API Key, just having an OAuth 2.0 object from the user that signed in and that wants to upload the processed video to their channel?

Uploading or inserting videos in to YouTube requires that you be authorized. What you do is send an authorization header with a bearer token as shown below.

curl --request POST \
  'https://youtube.googleapis.com/youtube/v3/videos \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{}' \
  --compressed

The main problem is that generally a YouTube user has a quota of 50 uploads per day

This is actually a hard limit imposed by YouTube itself it is not related to the api you are using. No one can upload more than 50 videos a day.

if I follow YouTube's docs I'd have to upload the videos through a Google Cloud Project Client (which gives me an API Key) and said client would have a predefined quota for all requests (which is about 2 videos per day).

Im not sure where you read this can i have a link to that doc?

First off api keys are used when accessing public data, for example public videos stored on youtube. you could do a video.search with an api key you dont need an access token. What it does is identify your project to google so it knows which project to deduct the quota from. But an access token does exactly that so you dont need both. In your case inserting a video you dont need an api key for that.

To be clear an api key should not give you access to insert a video as it can only access public things. IT cant upload to a privet user account with out permission and an api key has no permission.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your detailed answer. The docs I was referring to at developers.google.com/youtube/v3/docs/videos/insert?apix=true show a sample curl request which has a parameter for the API key in the request URL. That, for me, meant that I would have to set up a Google Project which then is subject to quota reduction. Though that's not what I want. If I just send the upload POST-request to Google (as you showed in your curl snippet), do I still affect quota or would there only be the constraint of the 50 uploads per day?
key is a default value and is not required. I have been trying to get google to remove that for ten years. 50 uploads per day per user / channel. Its the user that authenticates your app that gets the access token that is used. That is what defines the 50 limit. So if you authorize your app you get 50, if i also authorize your app i also get 50. But remember your going to be limited by the quota

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.