Logging in#

btdl keeps one saved login (a token file) at a time. You can point at a different file with --token (or BTDL_TOKEN), so several accounts can coexist side by side:

$ btdl --token ~/.config/btdl/hi-res auth token

The two ways to create a login:

Token login#

If you already have an access token (a TIDAL_ACCESS_TOKEN from a previous tool, or the Tidal web session token):

$ btdl auth login
access token:                      # hidden — not echoed to the terminal
logged in as user 1234567

or pass it straight (scripts, CI):

$ btdl auth login "$TIDAL_ACCESS_TOKEN"

Option

Meaning

ACCESS_TOKEN (positional, optional)

the token to save; prompted if omitted

--user-id

pin the login to a specific account (multi-account profiles)

The token is verified against Tidal before it is saved; a rejected token never lands on disk. (A purely numeric paste — a user id by mistake — is refused even before that verification: Tidal tokens are not numbers.) A Bearer prefix is tolerated and stripped — a paste copied straight out of a request header works as-is. A pasted JWT keeps its exp claim’s lifetime (auth token counts it down; token_type is web); a non-JWT paste has no knowable lifetime (seconds_left is null — not expired). The verification probes the PASTED token itself, so a dead paste (say, from a retired OAuth client) can only fail the paste — a working saved login is never replaced, rotated, or cleared by it.

Checking and leaving#

$ btdl auth            # bare: the session state (a network call)
logged_in: True
user_id: 1234567
client: Tidekeeper OAuth
...

$ btdl auth token      # offline: what the saved record says alone
$ btdl auth status     # online: record + refreshed subscription
$ btdl auth subscription   # plan, status, quality ceiling
$ btdl auth refresh    # rotate the token now (a pasted or dead login says "not refreshed")
$ btdl auth logout     # remove the saved login (and revoke it remotely)
$ btdl auth clear      # remove the saved login locally only (no revocation)

The revocation is best-effort: a failed revocation still clears the local login — the JSON payload is the honest false, and the human line says logged out (remote revocation failed) rather than pretending there was nothing to log out.

btdl auth status also shows the subscription’s quality ceiling, which is what decides the top of the quality chain.

A dead login is reported, not raised: when the last refresh failed, the status carries a last_auth_failure line (the JSON’s last_auth_failure) naming the reason — a rejected rotation, a deferral while the auth endpoint is degraded (a 429/5xx refresh answer), or a pasted login with no refresh token — and the subscription lookup degrades to nulls; the command still exits 0.

So does a missing login: with no saved record at all, auth status and auth token report the absence as facts (exit 0, logged_in: false, every fact null — the client’s registered persona name is the one that is not, and no request is spent), where the catalog verbs make the same absence a typed failure (no valid Tidal login available).

What you never see#

Login-style commands emit a safe summary of the saved record — user_id, client_id, country_code — never the token values. auth clients shows the public OAuth client registry the same way: ids, platforms, quality tiers; no client_secret ever reaches the output.

When something goes wrong#

An auth problem is reported with a hint pointing at both login paths:

$ btdl search "x"
btdl: error: no valid Tidal login available: call TidalClient.device_login() or TidalClient.login(token) first
btdl: hint: log in with 'btdl auth login' (paste a token) or 'btdl auth device-login' (URL + code)

Symptom

Meaning

Fix

no valid Tidal login available

no usable token at the resolved path

btdl auth device-login (or login)

token rejected by Tidal ... 401

the token is invalid or revoked

get a fresh token / re-run device login

subscription expired in auth status

the account lapsed

renew the account; the login stays valid

rate-limit messages

Tidal is throttling the client id

the library waits and backs off automatically; btdl auth rate-limit shows the current pace