<!-- Generated from the canonical OpenPost public page. Do not edit this build artifact. -->

Title: YouTube
Description: Create a Google OAuth client and connect a YouTube channel for video uploads.
Canonical: https://openpo.st/docs/self-hosting/integrations/youtube
Source: [https://openpo.st/docs/self-hosting/integrations/youtube](https://openpo.st/docs/self-hosting/integrations/youtube)

# YouTube

OpenPost connects a YouTube channel with Google OAuth and uploads one video per YouTube rendition. Google controls who can authorize your app and whether API uploads can be public.

## Before you start

- Set `OPENPOST_APP_URL` to your instance's public HTTPS origin.
- Use a Google account that has a YouTube channel. Have access to a [Google Cloud project](https://console.cloud.google.com/) where you can enable APIs and configure OAuth.
- Plan for Google's consent-screen verification and YouTube API audit if people outside your test group will use the app. [Unverified API projects created after July 28, 2020 have uploads restricted to private viewing](https://developers.google.com/youtube/v3/docs/videos/insert).

## Set up Google Cloud

1. Create or select a project in [Google Cloud Console](https://console.cloud.google.com/), then enable **YouTube Data API v3** in **APIs & Services → Library**. Enable **YouTube Analytics API** too if you will use Analytics.
2. In **Google Auth Platform**, configure the OAuth consent screen, audience, app details, and authorized domains. Add your own Google account as a test user while the app is in testing. In **Data Access**, add the scopes below; submit for verification when Google requires it.
3. In **Clients** (or **APIs & Services → Credentials**), create an **OAuth client ID** of type **Web application**. Add this **Authorized redirect URI**:

   ```text
   https://post.example.com/api/v1/accounts/youtube/callback
   ```

4. Save the client and copy its **Client ID** and **Client Secret**. Keep the secret in your instance's secret store.

OpenPost requests these scopes. Enter the full URLs in Google Auth Platform when configuring data access:

```text
https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/youtube.readonly
https://www.googleapis.com/auth/yt-analytics.readonly
https://www.googleapis.com/auth/youtube.upload
https://www.googleapis.com/auth/youtube
```

The [YouTube Analytics API](https://developers.google.com/youtube/analytics/reference/reports/query) must be enabled before OpenPost can read channel reports.

Google documents [YouTube OAuth](https://developers.google.com/youtube/v3/guides/authentication) and the [web-server OAuth client flow](https://developers.google.com/identity/protocols/oauth2/web-server).

![Google Cloud APIs and Services with Enable APIs and services highlighted](https://openpo.st/docs/assets/screenshots/integrations/google-enable-api.png)

Enable YouTube Data API v3 in the project that owns your OAuth client.

![Google OAuth web application client with the example OpenPost YouTube redirect URI](https://openpo.st/docs/assets/screenshots/integrations/youtube-callback.png)

Add the callback under Authorized redirect URIs. Replace post.example.com with your domain.

## Save the app in OpenPost

Use this provider entry when [saving your app credentials](https://openpo.st/docs/self-hosting/integrations#save-your-provider-credentials). Replace the example domain with your OpenPost address.

```json
[
  {
    "provider": "youtube",
    "client_id": "your-google-oauth-client-id",
    "client_secret": "your-google-oauth-client-secret",
    "redirect_uri": "https://post.example.com/api/v1/accounts/youtube/callback"
  }
]
```

## Connect and test

1. In **Settings → Workspace → Social accounts**, select **YouTube**. Sign in with the Google account that owns the target channel, grant consent, and choose the channel returned by Google.
2. Create a publication with one video and select the connected channel. Start with a **private** upload and confirm that OpenPost reports the result and the video appears in YouTube Studio.
3. Set title, description, privacy, and other YouTube options on the rendition as needed. Test public visibility separately: Google can keep API uploads private even when OpenPost requests another privacy level.

OpenPost also requests YouTube read, upload, broader YouTube, profile, email, and Analytics read scopes. Optional Comments and replies and Analytics start disabled per channel and need those permissions before you enable them.

## If it does not work

- **Google blocks consent:** Check the consent-screen audience, test-user list, requested scopes, and verification status.
- **No channel appears:** Confirm the signed-in Google identity has a channel available to the app and select the right account in Google's chooser.
- **Upload fails or stays private:** Confirm YouTube Data API v3 is enabled and read Google's error. A new unverified API project can only upload private videos until it passes the YouTube audit.
- **Redirect mismatch:** Compare the authorized redirect URI with the JSON and public `OPENPOST_APP_URL` exactly. Reconnect after changing scopes.
