# How the hosted sign-in works
URL: https://musicapi.com/docs/connect-users/how-sign-in-works.md

> The hosted sign-in connects a user's music account to your MusicAPI account and gives you an integrationUserUUID. The flow, the ids, and the setup each service needs.

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

Before MusicAPI can read a user's library, the user connects their music account. The hosted sign-in does that for every service with one link. You never handle the music service's OAuth flow yourself.

1. **Your app**: Opens `app.musicapi.com/{slug}` with your `returnUrl`.
2. **Service picker**: The user picks one of the services you turned on.
3. **Music service**: The user signs in and allows access.
4. **MusicAPI callback**: The service returns to `api.musicapi.com/callback/…`. MusicAPI stores the tokens.
5. **Your return URL**: The user comes back with `data64`: the result and the `integrationUserUUID`.

## The ids

| Id                    | What it names                                            | Where you get it                                  |
| --------------------- | -------------------------------------------------------- | ------------------------------------------------- |
| `slug`                | Your MusicAPI account, in the sign-in URL                | **Settings** in the dashboard. Yours is `{slug}`. |
| `authModel.uuid`      | One sign-in attempt                                      | The callback                                      |
| `integrationUserUUID` | One connected music account. Every library call uses it. | The callback                                      |
| `integrationUserId`   | The user's own id at the music service                   | The connected-user answers                        |

Store the `integrationUserUUID` with your own user. One person can connect several services. Each one is its own connected user with its own uuid. When the same music account signs in again, it gets the same uuid back.

## What the user sees

- Your business name and logo on the picker and the result pages. Set both under **Settings** in the dashboard.
- Only the services you turned on under **Integrations**. A [direct service link](https://musicapi.com/docs/connect-users/start-sign-in.md#skip-the-picker) skips the picker.
- The consent screen of the music service, for your developer app or for the MusicAPI managed app.

## Where the tokens go

MusicAPI stores the music-service tokens encrypted, and renews them when they expire. You call the API with the `integrationUserUUID`, never with the service's token. If you need the raw tokens to call the service yourself, read [Raw tokens and refresh](https://musicapi.com/docs/connect-users/raw-tokens-and-refresh.md).

## The pages of this section

1. [Start a sign-in](https://musicapi.com/docs/connect-users/start-sign-in.md): build the URL and its options.
2. [Handle the callback](https://musicapi.com/docs/connect-users/handle-callback.md): read `data64` and check the result.
3. [Poll the sign-in status](https://musicapi.com/docs/connect-users/poll-sign-in-status.md): for apps that cannot receive a redirect.
4. [Connected users](https://musicapi.com/docs/connect-users/connected-users.md): read a user and their service profile.
5. [Raw tokens and refresh](https://musicapi.com/docs/connect-users/raw-tokens-and-refresh.md).
6. [Disconnect and erase a user](https://musicapi.com/docs/connect-users/disconnect-users.md).

## Set up each service

Each service needs an integration on your account. A `transferring` sign-up gets managed integrations. Otherwise, register a developer app at the service. Every page lists the callback URL to register, the scopes and the quirks.

| Service      | Setup                                                                                    |
| ------------ | ---------------------------------------------------------------------------------------- |
| Spotify      | [Set up Spotify](https://musicapi.com/docs/connect-users/configure-spotify.md)           |
| Apple Music  | [Set up Apple Music](https://musicapi.com/docs/connect-users/configure-apple-music.md)   |
| YouTube      | [Set up YouTube](https://musicapi.com/docs/connect-users/configure-youtube.md)           |
| Tidal        | [Set up Tidal](https://musicapi.com/docs/connect-users/configure-tidal.md)               |
| Amazon Music | [Set up Amazon Music](https://musicapi.com/docs/connect-users/configure-amazon-music.md) |
| Deezer       | [Set up Deezer](https://musicapi.com/docs/connect-users/configure-deezer.md)             |
| SoundCloud   | [Set up SoundCloud](https://musicapi.com/docs/connect-users/configure-soundcloud.md)     |
| Boomplay     | [Set up Boomplay](https://musicapi.com/docs/connect-users/configure-boomplay.md)         |
| Audiomack    | [Set up Audiomack](https://musicapi.com/docs/connect-users/configure-audiomack.md)       |
| Audius       | [Set up Audius](https://musicapi.com/docs/connect-users/configure-audius.md)             |
| Qobuz        | [Set up Qobuz](https://musicapi.com/docs/connect-users/configure-qobuz.md)               |
| Resso        | [No longer available](https://musicapi.com/docs/connect-users/configure-resso.md)        |
