🎬 Open-source, self-hosted AI agent that runs a YouTube channel end to end: researches topics, writes scripts, generates narration, visuals and video, optimizes SEO, and publishes after your approval, then learns from analytics. Works with Gemini, OpenAI, OpenRouter, DeepSeek and more.
JavaScript ai-agentsautomationcontent-automationcontent-creationcontent-strategygoogle-geminijavascriptnodejsopenaiself-hostedseo-optimizationsocial-media-automationthumbnail-generatorvideo-generationyoutube-apiyoutube-automationyoutube-botyoutube-channelyoutube-shortsyoutube-uploader
feat: request youtube.force-ssl scope and detect granted scopes
darkzOGx0048fb83269b
diff --git a/modern-auth.js b/modern-auth.jsindex 583a961..10712f3 100644--- a/modern-auth.js+++ b/modern-auth.js@@ -33,7 +33,8 @@ class ModernAuth {'https://www.googleapis.com/auth/youtube.upload','https://www.googleapis.com/auth/youtube','https://www.googleapis.com/auth/youtube.readonly',- 'https://www.googleapis.com/auth/yt-analytics.readonly'+ 'https://www.googleapis.com/auth/yt-analytics.readonly',+ 'https://www.googleapis.com/auth/youtube.force-ssl'];// Start a temporary local serverdiff --git a/oauth-server.js b/oauth-server.jsindex 9dd5200..33cebe9 100644--- a/oauth-server.js+++ b/oauth-server.js@@ -124,7 +124,8 @@ class OAuthServer {'https://www.googleapis.com/auth/youtube.upload','https://www.googleapis.com/auth/youtube','https://www.googleapis.com/auth/youtube.readonly',- 'https://www.googleapis.com/auth/yt-analytics.readonly'+ 'https://www.googleapis.com/auth/yt-analytics.readonly',+ 'https://www.googleapis.com/auth/youtube.force-ssl'];const authUrl = oauth2Client.generateAuthUrl({diff --git a/test.js b/test.jsindex a4e01be..b2b8610 100644--- a/test.js+++ b/test.js@@ -49,7 +49,8 @@ class SystemTest {{ name: 'Configuration Files', test: () => this.testConfiguration() },{ name: 'Audience Comment Store', test: () => this.testAudienceCommentStore() },{ name: 'Engagement Insight Store', test: () => this.testEngagementInsightStore() },- { name: 'Reply Draft Lifecycle Store', test: () => this.testReplyDraftStore() }+ { name: 'Reply Draft Lifecycle Store', test: () => this.testReplyDraftStore() },+ { name: 'YouTube Scope Detection', test: () => this.testYouTubeScopeDetection() }];let passed = 0;@@ -2294,6 +2295,18 @@ class SystemTest {this.logger.info('Agent loading test completed successfully');}+ async testYouTubeScopeDetection() {+ const manager = new CredentialManager();+ const forceSsl = 'https://www.googleapis.com/auth/youtube.force-ssl';+ manager.tokens = { youtube: { scope: 'https://www.googleapis.com/auth/youtube.upload https://www.googleapis.com/auth/youtube' } };+ if (manager.hasYouTubeScope(forceSsl)) throw new Error('force-ssl must not be reported before consent');+ if (!manager.hasYouTubeScope('https://www.googleapis.com/auth/youtube')) throw new Error('Granted scopes must be detected');+ manager.tokens.youtube.scope += ` ${forceSsl}`;+ if (!manager.hasYouTubeScope(forceSsl)) throw new Error('force-ssl must be detected after consent');+ manager.tokens = {};+ if (manager.hasYouTubeScope('https://www.googleapis.com/auth/youtube')) throw new Error('Missing tokens must report no scopes');+ }+async testReplyDraftStore() {const db = new Database();await db.initialize();diff --git a/utils/credential-manager.js b/utils/credential-manager.jsindex 3f2d85f..b060f5f 100644--- a/utils/credential-manager.js+++ b/utils/credential-manager.js@@ -106,7 +106,8 @@ class CredentialManager {'https://www.googleapis.com/auth/youtube.upload','https://www.googleapis.com/auth/youtube','https://www.googleapis.com/auth/youtube.readonly',- 'https://www.googleapis.com/auth/yt-analytics.readonly'+ 'https://www.googleapis.com/auth/yt-analytics.readonly',+ 'https://www.googleapis.com/auth/youtube.force-ssl'];const authUrl = oauth2Client.generateAuthUrl({@@ -155,6 +156,11 @@ class CredentialManager {return google.youtube({ version: 'v3', auth });}+ hasYouTubeScope(scope) {+ const granted = String(this.tokens?.youtube?.scope || '');+ return granted.split(/\s+/).includes(scope);+ }+// OpenAI API Setupasync setupOpenAICredentials() {console.log(chalk.cyan('\n🤖 OpenAI API Setup'));