> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postqueen.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# YouTube setup

> Register the YouTube application and give PostQueen its keys

<img src="https://mintcdn.com/forceplay/LL5FipRv-7nhg1To/images/channels/youtube.svg?fit=max&auto=format&n=LL5FipRv-7nhg1To&q=85&s=558853850e88ddddb7bc7abc0d998d58" alt="YouTube" height="44" noZoom style={{ height: "44px", marginBottom: "1.25rem" }} data-path="images/channels/youtube.svg" />

On your own instance the Google Cloud project is yours: create the OAuth client, enable the YouTube APIs, then put the client id and secret in your environment.

Follow the instructions as available in the [Obtaining authorization credentials](https://developers.google.com/youtube/registering_an_application).

## General Setup

<Steps>
  <Step title="Go to Credentials Page">
    Make sure you are logged in to your Google account and visit the [Credentials - APIs & Services](https://console.cloud.google.com/projectselector2/apis/credentials) page. Make sure to read the terms and conditions and "Agree and Continue".
  </Step>

  <Step title="Create Project">
    Create a new project by clicking on the "Create Project" button. Fill in the project name, and details and click "Create".
  </Step>

  <Step title="Create OAuth Credentials">
    Create credentials by clicking on the "Create Credentials" button. Select the "OAuth client ID" option.
  </Step>

  <Step title="Configure Consent Screen">
    Navigate to the **OAuth consent screen** tab. If it is not already configured:

    1. Select "External" user type, unless you have a Google Workspace organization
    2. Fill in the required app information
    3. Add yourself as a test user
    4. Save and continue through the wizard

    On the **Scopes** step, add the eight PostQueen asks for. The connect is refused if any one of
    them is missing:

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

    <Info>
      While the app sits in **Testing**, only accounts you added as test users can connect. For an
      install you intend to keep, publish the app.
    </Info>
  </Step>

  <Step title="Fill in OAuth Details">
    Create the OAuth client ID. Select "Web application" as the application type and fill in the details.

    <Snippet file="oauth2redirect.mdx" />

    **Your YouTube OAuth2 Redirect URI:**

    * Production: `https://postqueen.example.com/integrations/social/youtube`
    * Local development: `http://localhost:4200/integrations/social/youtube`
    * Docker: `http://localhost:4007/integrations/social/youtube`

    Under "Authorized redirect URIs", insert your OAuth2 Redirect URI.

    <Frame>
      <img src="https://mintcdn.com/forceplay/Gsgj4WOu3HFxkte6/images/providers/youtube/youtube-001.png?fit=max&auto=format&n=Gsgj4WOu3HFxkte6&q=85&s=568a60fe59234ba68f6c21af7fe70993" alt="The OAuth client configuration in Google Cloud Console, with the Authorized redirect URIs field" width="784" height="733" data-path="images/providers/youtube/youtube-001.png" />
    </Frame>

    After following all of the steps above you should be met with a screen that shows your client ID and client secret. Add these to your providers configuration.

    ```env theme={"system"}
    YOUTUBE_CLIENT_ID=""
    YOUTUBE_CLIENT_SECRET=""
    ```
  </Step>

  <Step title="Add Test User">
    Add yourself as a test user of the application

    <Frame>
      <img src="https://mintcdn.com/forceplay/Gsgj4WOu3HFxkte6/images/providers/youtube/YouTube-Add-Test-Users.png?fit=max&auto=format&n=Gsgj4WOu3HFxkte6&q=85&s=a35fce18021c0998fc27c940f29559cb" alt="The OAuth consent screen test users panel, with the control for adding your own account" width="1477" height="885" data-path="images/providers/youtube/YouTube-Add-Test-Users.png" />
    </Frame>
  </Step>

  <Step title="Activate YouTube's API">
    Go to "Enabled APIs and Services". Then click on "Enable APIs and Services". Search "YouTube Data API v3" and activate the API by selecting it and clicking "Enable". Do the same Process with "YouTube Analytics API" and "YouTube Reporting API".

    <Frame>
      <img src="https://mintcdn.com/forceplay/Gsgj4WOu3HFxkte6/images/providers/youtube/YouTube-Enabled-APIs.png?fit=max&auto=format&n=Gsgj4WOu3HFxkte6&q=85&s=d664bd9be902f687b3f9c5b8bcb79ad1" alt="The Enabled APIs and Services page in Google Cloud Console" width="1918" height="867" data-path="images/providers/youtube/YouTube-Enabled-APIs.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/forceplay/Gsgj4WOu3HFxkte6/images/providers/youtube/Enable-APIs-and-Services.png?fit=max&auto=format&n=Gsgj4WOu3HFxkte6&q=85&s=bba415aaf7162a734b190814c97ff9b1" alt="The API library search results, with YouTube Data API v3 ready to enable" width="1136" height="367" data-path="images/providers/youtube/Enable-APIs-and-Services.png" />
    </Frame>
  </Step>

  <Step title="Restart and add the YouTube channel">
    <Snippet file="restart-and-add-channel.mdx" />
  </Step>
</Steps>

## Additional Steps for Brand Accounts

<Info>
  When using a Brand account you will need to set your APP to External and setup a test user. You do not need to publish the APP, but it does take time for the changes to propagate. You will also need to add the app to the trusted apps within your google workspace Admin.
</Info>

<Steps>
  <Step title="Go to admin.google.com">
    Sign in
  </Step>

  <Step title="Go to Security Settings">
    Go to Security → Access and data Controls → API Controls
    Click Manage Third Party App Access
  </Step>

  <Step title="Configure new App">
    Click "Configure new App"
    Put your Client ID for the app you created in previous steps into the search box and select your app
  </Step>

  <Step title="Set scopes and Google Data Access">
    Set scopes and Google Data Access for the app to Trusted
    Once set, click save
  </Step>

  <Step title="Wait for propagation">
    Wait at least 5 hours for the changes to propagate.
    After this time you should now be able to add your YouTube channel to your PostQueen account
  </Step>
</Steps>

## Next steps

<CardGroup cols={2}>
  <Card title="What she can post to YouTube" icon="https://mintcdn.com/forceplay/LL5FipRv-7nhg1To/images/channels/youtube.svg?fit=max&auto=format&n=LL5FipRv-7nhg1To&q=85&s=558853850e88ddddb7bc7abc0d998d58" href="/providers/youtube" width="64" height="64" data-path="images/channels/youtube.svg">
    Limits, post types and settings
  </Card>

  <Card title="Configuration reference" icon="list" href="/configuration/reference">
    Every variable she reads
  </Card>

  <Card title="Connect errors" icon="plug-circle-xmark" href="/troubleshooting/oauth-connect">
    Invalid state, invalid\_grant and the rest
  </Card>

  <Card title="Another channel" icon="plug" href="/providers/overview">
    Every network, and what each one asks for
  </Card>
</CardGroup>
