YouTube Post API Official Configuration Guide
This guide explains how to configure the official YouTube Data API for StackPosts YouTube video publishing. It covers Google Cloud setup, OAuth consent screen, OAuth credentials, YouTube scopes, callback URL, channel connection, video upload testing, quota notes, and common troubleshooting.
What This Integration Does
- Connect YouTube channels using Google OAuth 2.0.
- List authorized YouTube channels from the connected Google account.
- Publish one video file to a selected YouTube channel.
- Set video title, description, category, privacy, tags, and optional thumbnail.
- Refresh OAuth access tokens automatically using the stored refresh token.
Official APIs Used
| Purpose | API / Endpoint |
|---|---|
| OAuth Authorization | https://accounts.google.com/o/oauth2/v2/auth |
| OAuth Token Exchange | https://oauth2.googleapis.com/token |
| List Channels | GET https://www.googleapis.com/youtube/v3/channels |
| Upload Video | POST https://www.googleapis.com/upload/youtube/v3/videos |
| Set Thumbnail | POST https://www.googleapis.com/upload/youtube/v3/thumbnails/set |
Requirements
- A Google account with access to Google Cloud Console.
- A YouTube channel for testing and production use.
- A public domain with HTTPS enabled.
- Admin access to StackPosts integration settings.
- YouTube Data API v3 enabled in the Google Cloud project.
Important: Service accounts are not suitable for normal YouTube channel video publishing. YouTube channel publishing requires user OAuth consent.
Step 1: Create or Select a Google Cloud Project
- Open Google Cloud Console.
- Create a new project or select an existing project.
- Use a clear project name, for example
StackPosts YouTube. - Make sure the correct project is selected before enabling APIs or creating credentials.
Step 2: Enable Required APIs
Go to APIs & Services > Library and enable:
- YouTube Data API v3 - required for channel connection, video upload, and thumbnail upload.
- YouTube Analytics API - optional, only required if YouTube analytics sync is used.
Step 3: Configure OAuth Consent Screen
- Go to Google Auth Platform or APIs & Services > OAuth consent screen.
- Choose External if your users are outside your Google Workspace.
- Enter app name, user support email, developer contact email, homepage, privacy policy, and terms URLs.
- Add your production domain to Authorized domains.
- If the app is still in testing mode, add test Google accounts under Test users.
Step 4: Add OAuth Scopes
Minimum scopes for YouTube video publishing:
https://www.googleapis.com/auth/youtube
https://www.googleapis.com/auth/userinfo.email
Optional scope for YouTube Analytics:
https://www.googleapis.com/auth/yt-analytics.readonly
Request only the scopes that your installation uses. Sensitive scopes may require Google app verification before the integration can be used publicly.
Step 5: Create OAuth Client ID
- Go to APIs & Services > Credentials.
- Click Create Credentials > OAuth client ID.
- Select Web application.
- Add your production domain under Authorized JavaScript origins.
- Add the StackPosts callback URL under Authorized redirect URIs.
Production redirect URI:
https://your-domain.com/integrations/youtube/channel
Local development examples:
http://localhost/integrations/youtube/channel
http://127.0.0.1/integrations/youtube/channel
The redirect URI must match exactly, including http or https, domain, path, and trailing slash. A mismatch will cause the Google error redirect_uri_mismatch.
Step 6: Create API Key
- Go to APIs & Services > Credentials.
- Click Create Credentials > API key.
- Restrict the key where possible.
- For API restrictions, select YouTube Data API v3.
Step 7: Configure StackPosts
Open the StackPosts admin integration settings and configure YouTube:
| Field | Value |
|---|---|
| Status | Enabled |
| Client ID | OAuth Client ID from Google Cloud |
| Client Secret | OAuth Client Secret from Google Cloud |
| API Key | Google API key |
| Permissions | OAuth scopes separated by spaces |
| Callback URL | https://your-domain.com/integrations/youtube/channel |
Recommended permissions for posting video:
https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/userinfo.email
Step 8: Connect a YouTube Channel
- Log in to StackPosts as a user allowed to connect channels.
- Open the Channels area.
- Select YouTube Channel.
- Click Connect.
- Choose the Google account that owns or manages the YouTube channel.
- Grant the requested permissions.
- Select the YouTube channel returned by Google.
Step 9: Publish a Test Video
- Select one connected YouTube channel.
- Upload exactly one video file.
- Enter a video title.
- Set category ID, for example
22. - Choose privacy:
public,unlisted, orprivate. - Add comma-separated tags if needed.
- Add an optional thumbnail URL if needed.
- Publish the post and verify it in YouTube Studio.
Quota Notes
- YouTube Data API quota is counted per Google Cloud project.
- A video upload with
videos.insertuses 100 quota units. - The default YouTube Data API quota is commonly 10,000 units per day, but it may vary by project.
- Check quota usage in APIs & Services > Quotas.
Common Errors
| Error | Fix |
|---|---|
redirect_uri_mismatch |
Copy the exact StackPosts callback URL into Google OAuth Client authorized redirect URIs. |
access_denied |
Add the Google account as a test user or complete OAuth consent verification. |
| No channels returned | Make sure the Google account has a YouTube channel and YouTube Data API v3 is enabled. |
| No refresh token | Revoke the app from the Google account security page, then connect again. |
| Quota error | Check YouTube Data API quota and reduce repeated upload tests. |
Production Checklist
- YouTube Data API v3 is enabled.
- OAuth consent screen is fully configured.
- Production domain is added to authorized domains.
- OAuth Client ID type is Web application.
- Redirect URI is exactly
https://your-domain.com/integrations/youtube/channel. - Client ID and Client Secret are saved in StackPosts.
- YouTube integration status is enabled.
- Channel connection has been tested.
- Private or unlisted video upload has been tested before public publishing.
- Quota usage is monitored after upload tests.
Policy note: Some Google Cloud projects may need Google verification or YouTube API Services audit before public production use. In some cases, videos uploaded through unverified projects may be restricted.