We build custom applications 5x faster and cheaper 🚀
Book a Free Consultation
Stuck on an error? Book a 30-minute call with an engineer and get a direct fix + next steps. No pressure, no commitment.
Integrate YouTube with OpenClaw by building a small external web service that performs the OAuth 2.0 authorization code flow against Google, stores refresh/access tokens in a secure store, exposes a webhook endpoint for YouTube push notifications (PubSubHubbub/WebSub), and registers a skill in ClawHub that references those credentials and webhook URL. The OpenClaw skill should call Google’s YouTube Data API with the stored Bearer tokens (or use an API key for public-only reads), and long-lived concerns (token storage, webhook handling, scheduled refresh) must run outside the agent runtime. Debug with logs and API responses, verify OAuth scopes and webhook verification, and respect quotas and retry semantics.
https://www.googleapis.com/auth/youtube.readonly, https://www.googleapis.com/auth/youtube.upload). Request the least privilege needed.// Example authorization URL (open in browser)
https://accounts.google.com/o/oauth2/v2/auth?client_id=YOUR_CLIENT_ID&redirect_uri=https://your-service.example.com/oauth/callback&response_type=code&scope=https://www.googleapis.com/auth/youtube.readonly%20https://www.googleapis.com/auth/youtube.upload&access_type=offline&prompt=consent
// Exchange authorization code for tokens
curl -X POST https://oauth2.googleapis.com/token \
-d client_id=YOUR_CLIENT_ID \
-d client_secret=YOUR_CLIENT_SECRET \
-d code=AUTH_CODE \
-d redirect_uri=https://your-service.example.com/oauth/callback \
-d grant_type=authorization_code
// Minimal Node/Express webhook handler (verification + notification)
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.text({ type: '*/*' })); // <b>//</b> PubSubHubbub sends XML or text
// <b>//</b> Verification (GET)
app.get('/youtube/webhook', (req, res) => {
const mode = req.query['hub.mode'];
const challenge = req.query['hub.challenge'];
const topic = req.query['hub.topic'];
// <b>//</b> Validate topic and mode as needed
if (challenge) {
res.status(200).send(challenge);
} else {
res.sendStatus(400);
}
});
// <b>//</b> Notification (POST)
app.post('/youtube/webhook', (req, res) => {
const raw = req.body; // <b>//</b> XML body with <feed><entry>...
// <b>//</b> Acknowledge quickly
res.sendStatus(204);
// <b>//</b> Parse raw XML and act: fetch video details with your stored tokens
});
app.listen(3000);
// Get channel details (example)
curl -H "Authorization: Bearer ACCESS_TOKEN" \
"https://www.googleapis.com/youtube/v3/channels?part=contentDetails,snippet&mine=true"
// Get video metadata
curl -H "Authorization: Bearer ACCESS_TOKEN" \
"https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id=VIDEO_ID"
Run the OAuth and webhook handling as a small dedicated web service (or serverless endpoints) outside the OpenClaw agent. Use the agent/skill only to perform immediate API calls or orchestrate user-facing behavior. Store refresh tokens and do scheduled token refreshes outside the agent. This separation gives you reliability, observability, and secure secret management while keeping the skill code simple and focused.
Speak one‑on‑one with a senior engineer about your no‑code app, migration goals, and budget. In just half an hour you’ll leave with clear, actionable next steps—no strings attached.
1
The error means the OAuth redirect_uri sent in your YouTube/Google authorization request does not exactly match the URI registered for your OAuth client. Fix by making the URI strings identical (scheme, host, path, trailing slash) and by using the same value in OpenClaw/ClawHub skill config and the Google Cloud Console.
Check the redirect_uri your skill uses, register that exact value in Google Cloud -> OAuth 2.0 Client IDs, and ensure the skill/runtime env var points to the same URL. Use HTTPS for production, localhost for local testing.
// Build auth URL using env var so it matches registered URI
const redirect = process.env.OAUTH_REDIRECT_URI; // <b>//</b> must match Google Console
const url = `https://accounts.google.com/o/oauth2/v2/auth?client_id=${process.env.CLIENT_ID}&redirect_uri=${encodeURIComponent(redirect)}&response_type=code&scope=youtube.readonly&access_type=offline`;
2
Quota exceeded means the YouTube Data API limits were hit. Fixes: reduce request volume, use incremental imports and batching, implement exponential backoff with jitter, cache responses, move heavy ingestion outside the OpenClaw agent runtime, and request a quota increase in Google Cloud Console.
// Node.js example: simple backoff + incremental import
const axios = require('axios');
const API_KEY = process.env.YT_API_KEY;
// lastImport stored externally; example value:
let lastImport = process.env.LAST_IMPORT_TS || 0;
async function fetchNewVideos(pageToken, attempt=0){
try{
const res = await axios.get('https://www.googleapis.com/youtube/v3/playlistItems',{
params:{playlistId:'UPLOADS_PLAYLIST_ID', part:'snippet', maxResults:50, pageToken, key:API_KEY, publishedAfter:lastImport}
});
return res.data;
}catch(e){
if ((e.response && [429,403].includes(e.response.status)) && attempt<5){
await new Promise(r=>setTimeout(r, Math.pow(2,attempt)*1000 + Math.random()*500));
return fetchNewVideos(pageToken, attempt+1);
}
throw e;
}
}
3
Most likely the PubSubHubbub (WebSub) verification fails because the OpenClaw skill’s callback URL is unreachable, misconfigured, or not returning the exact verification response (echo hub.challenge) with a 200 status. Check TLS, redirects, verify_token, and that ClawHub/skill configuration uses the same callback URL and token.
Fix steps:
4
If your OpenClaw YouTube connector returns 308 Resume Incomplete or fails to finalize uploads, it usually means the resumable session wasn’t completed (wrong Content-Range/offset, lost session URL, or wrong OAuth scope). Fix by ensuring correct headers, persisting the session URL outside the agent runtime, and retrying from the reported offset until the final chunk is accepted.
Key checks:
This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.
From startups to enterprises and everything in between, see for yourself our incredible impact.
Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We’ll discuss your project and provide a custom quote at no cost.Â