2

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:

enter image description here

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?

1 Answer 1

0

The user has exceeded the number of videos they may upload.

That error is unrelated to your quota. A user can max upload 100 videos in a day last i checked.

Solution is to change authenticated users of your app.

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

4 Comments

@linda-lawton-daimto AFAIK I can programmatically upload videos to YouTube only with the chanel owner authentication. What do you mean by "to change authenticated users of your app"?
You can have more then one channel owner / moderator. change it between two and each will be able to upload 100 videos.
@linda-lawton-daimto I checked 5 different days when I got the errors and I see I got the limit error already on the 11th or 12th video upload.
I'm getting 401 Unauthorized - youtubeSignupRequired error when authenticating with other owner I added to the channel

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.