# Set up YouTube
URL: https://musicapi.com/docs/connect-users/configure-youtube.md

> What you need from the Google Cloud console (YouTube Data API v3, consent screen, OAuth client), the redirect URI and scopes, and the YouTube limits.

Product: MusicAPI Core and MusicAPI Managed Transfers. Section: Connect your users.

The `youtube` integration connects a Google account and works on its YouTube and YouTube Music library through the YouTube Data API. YouTube Music playlists and liked songs are YouTube playlists.

> **Managed integration:** A `transferring` sign-up gets copies of the integrations that MusicAPI runs. When your **Integrations** page already lists YouTube, users can sign in with no setup on your side. Set up your own Google project when your account has no YouTube integration, or when your users must see your app on the Google consent screen.

## What you need from Google

1. **Create a project**

   In the [Google Cloud console](https://console.cloud.google.com/apis/credentials), create a project.
2. **Turn on the API**

   Under **Enabled APIs and services**, enable **YouTube Data API v3**.
3. **Set up the consent screen**

   Pick the user type, set the app name and a developer contact email, and add the scopes below. While the app is not verified, add your testers as **Test users**.
4. **Create the OAuth client**

   Under **Credentials**, create an **OAuth client ID** of type **Web application** and add the redirect URI below.
5. **Copy the credentials**

   Copy the **Client ID** and the **Client secret**.

## Redirect URI

Add this exact URI under **Authorized redirect URIs**:

```url
https://api.musicapi.com/callback/youtube
```

## Scopes

```text
https://www.googleapis.com/auth/youtube
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile
```

The user must allow every scope. When the user unticks one, the sign-in fails with `errorType: "missingScopes"`.

The `youtube` scope is a sensitive scope. Google must verify your app before people outside your test users can sign in.

## Add it to MusicAPI

1. Open **Integrations** in the dashboard and pick YouTube.
2. Paste the Client ID and the Client Secret, and save.
3. Turn **Is Enabled** on.
4. Press **Test YouTube** and sign in once with your own Google account.

## Quirks

- Playlists work: read, create, rename, delete, add, remove and reorder items.
- There are no saved albums or followed artists, and no liked-track writes.
- YouTube gives no ISRC, so matching into YouTube uses the title and the artist. YouTube titles often mix both.
- Each Google project has a daily YouTube Data API quota. A busy project can run out before the day ends.
- At most 50 items per page (`limitParam`).

## Direct sign-in link

```url
https://app.musicapi.com/{slug}/youtube/auth?returnUrl={returnUrl}
```
