I'm using google YouTube API to programmatically upload videos to YouTube using my node.js server
I've installed googleapis npm package on my server, and authenticate each request with OAuth2 google auth.
On 03/07/2024 and 04/07/2024 I got several rate limit errors - uploadLimitExceeded while trying to upload videos to the YouTube channel. My daily quota is 220K and I was not even close to the limit:
The relevant code I use to upload a video:
const getAuth = async () => {
const oAuth2Client = new google.auth.OAuth2(youtubeApiClientId, youtubeApiClientSecret, youtubeRedirectUrl);
oAuth2Client.setCredentials({
refresh_token: youtubeApiRefreshToken,
});
await oAuth2Client.refreshAccessToken();
return oAuth2Client;
};
const uploadVideo = async ({ videoAsset, fileAccessToken }) => {
const fileName = `recording_${videoAsset._id.toString()}.${videoAsset.zoomDetails.fileType}`;
try {
await downloadRecording(videoAsset.zoomDetails.downloadUrl, fileAccessToken, fileName);
const auth = await getAuth();
const service = google.youtube({ version: 'v3', auth });
const params = {
auth,
part: 'snippet,status',
requestBody: {
snippet: {
title: getValidYoutubeTitle(videoAsset),
defaultLanguage: langCode,
},
status: {
privacyStatus: 'unlisted',
},
},
media: {
body: fs.createReadStream(fileName),
},
};
const response = await service.videos.insert(params);
return response;
} catch (error) {
// handle errors
}
};
An example of an error I got:
{
error: {
code: 400,
message: 'The user has exceeded the number of videos they may upload.',
errors: [
{
message: 'The user has exceeded the number of videos they may upload.',
domain: 'youtube.video',
reason: 'uploadLimitExceeded',
},
],
},
},
What could be the reason for the limit errors I got?
