The request cannot be completed because you have exceeded your quota
Asked Answered
P

2

26

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

Plymouth answered 20/10, 2019 at 0:58 Comment(2)
I'll ask a dumb question: Are you using the correct account credentials?Shick
yes, I signed in with google signin successfully and used the right key and right token,Plymouth
I
19

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

Icarus answered 20/10, 2019 at 1:3 Comment(3)
Thanks for your response, I understand now, but I have another question, when I executed the upload function, the onComplete callback function is never called even I waited for a long time, and I checked my account and all the uploads, there is a couple of videos showing Processing abandoned, The video could not be processed, not sure what is the issue behind.Plymouth
I'll be honest and say I do not know, I only quickly checked the API docs for this specific issue - Reading through them will probably explain how requests are handled when usage limits are metIcarus
I haven't used any quota yet, but it still says: "exceeded your quota": imgur.com/a/LM0sxlR I use Captions: download from youtube API.Sivan
P
21

Corrupt Google Developer Project - create a new one

I am disappointed in Google that this was the case for me.

I had the same issue, no usage at all but "quota exceeded" response. My solution was to create a new project. I guess it's because something changed internally over time and wasn't applied correctly to (at least my) already existing project...

I had stopped using AWS for several reasons and thought Google Cloud would be a refreshing experience but this shows me Google treats existing projects as badly as new products that it kills off. Strike one against Google.

https://github.com/googleapis/google-api-nodejs-client/issues/2263#issuecomment-741892605

Poultry answered 19/5, 2021 at 3:18 Comment(3)
Same thing happened to me. They just reset my quota to 0 for all API request. It took a week to get the last project verified and now I have to do this stupidity all over again :/Hizar
same issue here, thanks for the solution.. yet again, both AWS and GCP create more problems than they solve.. "cloud" hype train pain..Ophiolatry
Amazing discovery, thank you for sharing!Unicef
I
19

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

Icarus answered 20/10, 2019 at 1:3 Comment(3)
Thanks for your response, I understand now, but I have another question, when I executed the upload function, the onComplete callback function is never called even I waited for a long time, and I checked my account and all the uploads, there is a couple of videos showing Processing abandoned, The video could not be processed, not sure what is the issue behind.Plymouth
I'll be honest and say I do not know, I only quickly checked the API docs for this specific issue - Reading through them will probably explain how requests are handled when usage limits are metIcarus
I haven't used any quota yet, but it still says: "exceeded your quota": imgur.com/a/LM0sxlR I use Captions: download from youtube API.Sivan

© 2022 - 2024 — McMap. All rights reserved.