Skip to content

Authentication ​

YouTube Music ​

YouTube Music has no official API; tunesync uses ytmusicapi with a browser session.

bash
tunesync auth ytmusic
  1. Opens a clean Chrome or Edge window using a dedicated profile inside tunesync's data folder (your personal browser is never touched).
  2. Log in to your Google account and open Library if needed.
  3. Once detected and verified against YouTube Music, the window closes automatically and saves browser.json.

Silent background refresh ​

If Google ever rotates or expires session cookies later, renew them silently without typing your password again:

bash
tunesync auth ytmusic --refresh

Headless / manual fallback ​

On a server without Chrome or Edge, copy any browse request from music.youtube.com DevTools (Network → Copy as cURL):

bash
tunesync auth ytmusic --clipboard
# or from a temporary file (delete it afterwards):
tunesync auth ytmusic --file request.txt

Spotify ​

Option 1: Exportify CSV (no Spotify auth needed) ​

Export your playlist from exportify.app and run tunesync import. No Spotify Premium, no Developer app, and zero risk to your Spotify account.

Option 2: Official Spotify Web API (PKCE) ​

Requires a Spotify Premium account (since 2026) to own a Developer Dashboard app:

  1. Create an app at developer.spotify.com/dashboard.
  2. Add http://127.0.0.1:8888/callback under Redirect URIs.
  3. Enable Web API and copy your Client ID.
  4. Export SPOTIFY_CLIENT_ID and run:
bash
# PowerShell
$env:SPOTIFY_CLIENT_ID="your-client-id"
# Bash / zsh
export SPOTIFY_CLIENT_ID="your-client-id"

tunesync auth spotify

Option 3: Spotify web backend (experimental) ​

When no SPOTIFY_CLIENT_ID is set, tunesync can use Spotify's private web-player API with your sp_dc cookie:

bash
tunesync auth spotify --method web

When Chrome or Edge is installed, a clean window opens on open.spotify.com, waits for you to log in, verifies the token, and saves sp_dc automatically. For non-interactive scripts:

bash
tunesync auth spotify --method web --sp-dc "<value>" --i-know

Account risk

Spotify's terms prohibit automated access to its private web API. If you use --method web, consider using a secondary account invited as a collaborator on your playlists. Liked songs are read-only in web mode.