{"slug": "how-to-authorize-a-youtube-ai-agent-to-auto-upload-videos-forever-no-custom", "title": "How to Authorize a YouTube AI Agent to Auto-Upload Videos Forever (No Custom Domain)", "summary": "A developer documented a workaround for keeping a YouTube upload agent authorized indefinitely without owning a custom domain, by publishing a Google Cloud OAuth app to production so refresh tokens stop expiring every seven days. The guide walks through the Google Cloud Console Audience and Branding pages, using placeholder authorized domains like github.com to unlock the Publish app button, and stresses that tokens generated while the app was in Testing mode must be regenerated afterward because publishing does not retroactively save them.", "body_md": "Building an AI agent or automated pipeline that generates, edits, and uploads videos to YouTube is a massive time-saver—until your pipeline silently crashes a week later with an `invalid_grant` error.\n\nWhen you connect a personal script, n8n workflow, or custom YouTube agent to the **YouTube Data API v3**, Google puts your project in **Testing** mode by default. In Testing mode, **Google kills your OAuth refresh token every 7 days.** \n\nIf you want your YouTube agent to upload videos on autopilot without forcing you to manually re-authenticate every week, you have to push your app to **Production**. However, navigating between Google's developer tools—and dealing with hidden UI traps when you don't own a custom domain—trips up almost everyone on their first try.\n\nHere is the complete breakdown of the two platforms you need to use, and **every single caveat** you need to bypass to keep your YouTube agent connected permanently.\n\nBefore touching any settings, it helps to separate the two distinct Google tools involved in this setup:\n\n`://google.com`):\nTo stop the 7-day token expiration, you must switch your app from **Testing** to **In production** inside the **Google Cloud Console** under **Google Auth Platform > Audience**.\n\nWhen you open the **Audience** page, you will likely find the **Publish app** button disabled with this notice:\n\n*\"To publish your app, you must complete your configuration on the Branding page.\"*\n\nIf you jump over to the **Branding** page and leave the **Authorized domains** field blank—or leave an empty text input box open—Google blocks you with `Invalid domain: must not be empty`. \n\nEven worse, Google's updated interface strictly requires an **Application home page**, a **Privacy policy link**, and at least one **Authorized domain** before unlocking the Publish button.\n\n**How to fix it without buying a domain:**\n\nBecause this agent is strictly for your own YouTube channel, you do not need to buy a domain or build a website:\n\n`https://github.com`) or a public Google Doc stating that the app is a private automation tool for your personal channel.`https://github.com#privacy`).` github.com` or `google.com`). Return to the **Audience** page and refresh the browser. The **Publish app** button will now be clickable. Click it and confirm.\n\nBecause uploading videos (`youtube.upload`) is classified as a sensitive scope, Google will immediately prompt you to **Submit for verification** with a warning about unverified apps.\n\n**Ignore and close this prompt.**\n\n*(Note: If you happen to use a paid Google Workspace account rather than a standard `@gmail.com` account, you can avoid publishing altogether by setting your **User type** to **Internal**—Internal apps never expire refresh tokens).*\n\nNow switch over to the **Google OAuth 2.0 Playground** (`://google.com`) to generate the actual credential your YouTube agent will use.\n\nBy default, the OAuth Playground uses Google's generic public Client ID, whose tokens expire within hours.\n\nIn **Step 1** on the left sidebar, select the two scopes your YouTube agent needs to upload and edit videos:\n\n`https://googleapis.com`\nClick **Authorize APIs**. When you log in, Google will show a warning screen saying *\"Google hasn't verified this app.\"* Click **Advanced** at the bottom left, then click **Go to [Your Agent Name](https://dev.tounsafe)**.\n\nOnce redirected back to the Playground, look carefully at **Step 2**:\n\n`4/0A...`) is `\"refresh_token\"` (it always starts with `1//`). This is the biggest trap of all: **switching your app to \"In production\" does not retroactively save refresh tokens you generated while in Testing mode.** \n\nRefresh tokens inherit the publishing status of your Google Cloud project at the exact second they are created. If you generated a token before clicking *Publish app*, throw it away and generate a brand-new one in the Playground now.\n\nOnce you paste that production `\"refresh_token\"` into your YouTube agent's `.env` file or workflow manager, it will automatically fetch fresh 1-hour access tokens behind the scenes forever. \n\nGoogle will only invalidate a production refresh token if:\n\nWith those caveats cleared, your YouTube agent is ready to run hands-free!", "url": "https://wpnews.pro/news/how-to-authorize-a-youtube-ai-agent-to-auto-upload-videos-forever-no-custom", "canonical_source": "https://dev.to/mendy_kevin_94ec1db73e1df/how-to-authorize-a-youtube-ai-agent-to-auto-upload-videos-forever-no-custom-domain-3d9f", "published_at": "2026-11-18 19:37:45+00:00", "updated_at": "2026-11-18 19:42:04.455833+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools"], "entities": ["Google", "YouTube", "Google Cloud Console", "YouTube Data API v3", "Google OAuth 2.0 Playground", "GitHub"], "also_reported_by": [], "takeaway": "Refresh tokens inherit the app's publishing status at creation, so after switching a Google Cloud OAuth app from Testing to Production you must regenerate the refresh token or it still expires in seven days.", "recommendation": {"advice": "Publish your Google Cloud OAuth app to Production before generating credentials, then create a fresh refresh token in the OAuth Playground, since tokens made in Testing mode expire after seven days.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/how-to-authorize-a-youtube-ai-agent-to-auto-upload-videos-forever-no-custom", "markdown": "https://wpnews.pro/news/how-to-authorize-a-youtube-ai-agent-to-auto-upload-videos-forever-no-custom.md", "text": "https://wpnews.pro/news/how-to-authorize-a-youtube-ai-agent-to-auto-upload-videos-forever-no-custom.txt", "jsonld": "https://wpnews.pro/news/how-to-authorize-a-youtube-ai-agent-to-auto-upload-videos-forever-no-custom.jsonld"}}