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