This guide walks you through the complete YouTube API setup process, from creating credentials to authenticating your channel.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/darkzOGx/youtube-automation-agent/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before starting, ensure you have:- A YouTube channel
- A Google account with access to the channel
- Google Cloud Console access
Step 1: Create Google Cloud Project
Open Google Cloud Console
Create New Project
- Click the project dropdown at the top
- Click “New Project”
- Enter project details:
- Project name:
YouTube Automation Agent - Organization: Leave default or select your organization
- Project name:
- Click “Create”
Step 2: Enable YouTube APIs
Navigate to APIs & Services
- Select your project from the dropdown
- Click on the hamburger menu (☰)
- Go to “APIs & Services” → “Library”
Enable YouTube Data API v3
- Search for “YouTube Data API v3”
- Click on it
- Click “Enable”
Step 3: Configure OAuth Consent Screen
Before creating credentials, you must configure the OAuth consent screen:Select User Type
Internal vs External
Internal vs External
- Internal: Only for Google Workspace organizations
- External: For personal accounts and general use (choose this)
Fill App Information
Configure Scopes
- Click “Add or Remove Scopes”
- Add these YouTube scopes:
What each scope does
What each scope does
youtube.upload- Upload videosyoutube- Manage videos and channelyoutube.readonly- Read channel informationyt-analytics.readonly- Access analytics data
- Click “Update”
Add Test Users (Optional)
Step 4: Create OAuth 2.0 Credentials
Configure Application Type
YouTube Automation OAuth ClientAdd Authorized Redirect URIs
Step 5: Configure Application
Now add the credentials to your application:- Using credentials.json
- Using Setup Wizard
- Using Downloaded JSON
config/credentials.json:Step 6: Authenticate Your Channel
Now authenticate the application with your YouTube channel:Authorization URL
Grant Permissions
- Sign in with your Google account (if not already signed in)
- Select the YouTube channel to authorize
- Review the requested permissions:
- Upload videos
- Manage your YouTube account
- View YouTube Analytics reports
- Click “Allow”
Copy Authorization Code
localhost:8080.If shown a code:- Copy the code
- Paste it into the terminal when prompted
- The application will automatically capture the code
- Authentication will complete automatically
Step 7: Verify Configuration
Test that everything is working:Run Test Script
- YouTube API connection
- Channel access
- Upload permissions
- Analytics access
Channel Configuration
Configure channel-specific settings inconfig/credentials.json:
Video Category IDs
YouTube Category Reference
YouTube Category Reference
| ID | Category |
|---|---|
| 1 | Film & Animation |
| 2 | Autos & Vehicles |
| 10 | Music |
| 15 | Pets & Animals |
| 17 | Sports |
| 19 | Travel & Events |
| 20 | Gaming |
| 22 | People & Blogs |
| 23 | Comedy |
| 24 | Entertainment |
| 25 | News & Politics |
| 26 | Howto & Style |
| 27 | Education |
| 28 | Science & Technology |
| 29 | Nonprofits & Activism |
Privacy Settings
- public
- unlisted
- private
- Appears in search results
- Recommended to viewers
- Counts toward watch time
- Eligible for monetization
Content Strategy Configuration
Configure what types of content to generate:Content Types
Tutorial
Explainer
List
Story
Review
Posting Schedule
Configure automated posting:Frequency Options
| Value | Description |
|---|---|
daily | One video per day |
every-2-days | Every other day |
3-per-week | Three times per week |
weekly | Once per week |
custom | Define custom cron schedule |
Best Posting Times
By Audience Location
By Audience Location
- 12:00 PM - 4:00 PM EST (lunch/afternoon)
- 7:00 PM - 10:00 PM EST (evening)
- 2:00 PM - 4:00 PM CET
- 8:00 PM - 10:00 PM CET
- 1:00 PM - 3:00 PM UTC
Token Refresh
OAuth tokens expire periodically. The system automatically refreshes them:Quota Management
YouTube API has daily quota limits:- Default quota: 10,000 units/day
- Upload video: 1,600 units
- Update video: 50 units
- List videos: 1 unit
Monitor Usage
Check quota usage in Google Cloud Console:- Select your project
- Navigate to “APIs & Services” → “YouTube Data API v3”
- Click “Quotas”
Request Quota Increase
If you need more quota:- Go to “IAM & Admin” → “Quotas”
- Filter for “YouTube Data API v3”
- Select the quota to increase
- Click “Edit Quotas”
- Fill out the request form
Troubleshooting
Error: redirect_uri_mismatch
Error: redirect_uri_mismatch
- Check that redirect URI in code matches Google Cloud Console exactly
- Ensure there are no trailing slashes or typos
- Verify the port number matches
- Go to Credentials → OAuth 2.0 Client IDs
- Edit your client
- Update redirect URIs
Error: Access Not Configured
Error: Access Not Configured
- Ensure YouTube Data API v3 is enabled in your project
- Wait a few minutes after enabling APIs
- Clear browser cache and try again
Error: Invalid Credentials
Error: Invalid Credentials
- Verify client_id and client_secret are correct
- Check for extra spaces or line breaks when copying
- Re-download credentials JSON from Google Cloud Console
Token Expired Errors
Token Expired Errors
Quota Exceeded
Quota Exceeded
- Wait until quota resets (daily at midnight Pacific Time)
- Reduce upload frequency
- Request quota increase
- Use
GLOBAL_RATE_LIMIT_PER_HOURto throttle requests
Security Best Practices
Protect Credentials
- Never commit
credentials.jsonortokens.jsonto git - Add to
.gitignore - Use environment variables in production
Rotate Keys
- Regenerate OAuth credentials every 6 months
- Delete old unused credentials
- Use different credentials for dev/prod
Limit Scopes
- Only request necessary OAuth scopes
- Review permissions periodically
- Revoke unused authorizations
Monitor Access
- Check authorized apps in Google Account settings
- Enable 2FA on Google account
- Review API access logs