Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The request cannot be completed because you have exceeded your quota

I tried to use the javascript MediaUploader.js to upload youtube video to my own account, for some reason, I got this error in onError function:

"errors": [
   {
    "domain": "youtube.quota",
    "reason": "quotaExceeded",
    "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e."
   }
  ],
  "code": 403,
  "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e."

I only tested a few times today, but got this strange error.

var signinCallback = function (tokens, file){
console.log("signinCallback tokens: ",tokens);
if(tokens.accessToken) { //tokens.access_token
  console.log("signinCallback tokens.accessToken: ",tokens.accessToken);
  var metadata = {
    id: "101",
    snippet: {
      "title": "Test video upload",
      "description":"Description of uploaded video",
      "categoryId": "22",//22
      "tags": ["test tag1", "test tag2"],
    },
    status: {
        "privacyStatus": "private",
        "embeddable": true,
        "license": "youtube"
    }
    };
  console.log("signinCallback Object.keys(metadata).join(','): ",Object.keys(metadata).join(','));
  var options = {
    url: 'https://www.googleapis.com/upload/youtube/v3/videos?part=snippet%2Cstatus&key=<my api key>',

    file: file,
    token: tokens.accessToken,
    metadata: metadata,
    contentType: 'application/octet-stream',//"video/*",
    params: {
      part: Object.keys(metadata).join(',')
    },
    onError: function(data) {
      var message = data;
      // Assuming the error is raised by the YouTube API, data will be
      // a JSON string with error.message set. That may not be the
      // only time onError will be raised, though.
      try {
        console.log("signinCallback onError data: ",data);
        if(data!="Not Found"){
            var errorResponse = JSON.parse(data);
            message = errorResponse.error.message;
            console.log("signinCallback onError message: ",message);
            console.log("signinCallback onError errorResponse: ",errorResponse);
        }else{

        }
      } finally {
        console.log("signinCallback error.... ");
      }
    }.bind(this),
    onProgress: function(data) {
      var currentTime = Date.now();
      var bytesUploaded = data.loaded;
      var totalBytes = data.total;
      // The times are in millis, so we need to divide by 1000 to get seconds.
      var bytesPerSecond = bytesUploaded / ((currentTime - this.uploadStartTime) / 1000);
      var estimatedSecondsRemaining = (totalBytes - bytesUploaded) / bytesPerSecond;
      var percentageComplete = (bytesUploaded * 100) / totalBytes;
      console.log("signinCallback onProgress bytesUploaded, totalBytes: ",bytesUploaded, totalBytes);
      console.log("signinCallback onProgress percentageComplete: ",percentageComplete);
    }.bind(this),
    onComplete: function(data) {
      console.log("signinCallback onComplete data: ",data);
      var uploadResponse = JSON.parse(data);
      this.videoId = uploadResponse.id;
      //this.pollForVideoStatus();
    }.bind(this)
  }
  MediaUpload.videoUploader(options);
}

};

I checked the developer console of my quota, my quota limit is so big, there is no way I exceeded my quota, ex, I have total of 89 queries today, and my quota limit is 10,000 queries/day.

Expected: upload my video to my youtube account successfully. Actual results: quotaExceeded

like image 839
Geo Avatar asked Oct 20 '19 00:10

Geo


People also ask

What does it mean when YouTube says you have exceeded your quota?

I'm getting an error that says I exceeded my quota when uploading to YouTube. There is a slight chance that Explain Everything service will exceed its YouTube quota. This can happen if there is an exceptionally large amount of uploads to YouTube made from Explain Everything apps across the world.

How do I fix YouTube daily limit exceeded?

If so, we suggest that you try things like reducing your gallery's page size or using the plugin's caching feature. After that, your traffic might be so high that you still get the "Youtube Data API quota exceeded" error message. For that, you'll need to request that Google/YouTube give you a higher daily limit.

How do I increase quota on YouTube API?

If you have completed an API Compliance Audit within the last 12 months but require an additional quota extension, please fill out and submit the Audited Developer Requests Form. If you have recently failed an API Compliance Audit and would like to appeal that decision, please fill out and submit the Appeals Form.


1 Answers

Youtube does not give you 10,000 Queries a day, they give you 10,000 units a day; a query can be multiple units, depending on what you're doing:

A simple read operation that only retrieves the ID of each returned resource has a cost of approximately 1 unit.

A write operation has a cost of approximately 50 units.

A video upload has a cost of approximately 1600 units.

If your 89 queries contain video uploads or write operations, then that would explain your issue

More Information: https://developers.google.com/youtube/v3/getting-started#quota

like image 166
Shiny Avatar answered Oct 14 '22 19:10

Shiny