Authorization API
Melon signs devices in with sessions. Each signed-in device holds a short-lived access token and a refresh token, and shows up in the account's device list where it can be signed out.
For more information on Users, check the Melon User Guide.
Tokens
- Access token: a JWT that lasts 15 minutes. Send it as
Authorization: Bearer <token>. It is refused in the query string. - Refresh token: opaque, single use. Swap it at
auth/refreshfor a new pair before or after the access token expires. Using an old refresh token again signs that device out (it was likely stolen). Sessions end after 60 days without use, when the password changes, or when they're signed out. - Media token: a read-only JWT that lasts 6 hours, for URLs that can't carry a header (audio,
playlist and collection art). Pass it as
?jwt=<token>. It works only onapi/download/*.
Summary of Endpoints
| Endpoint | Method | Body | Description | Authorization |
|---|---|---|---|---|
/api/server/features | GET | What the server supports, e.g. ["stat-filters","auth-v2"]. | None | |
/auth/token | POST | {deviceName} plus Authorization: Basic base64(username:password) | Sign in and start a session. | None (rate limited) |
/auth/refresh | POST | {refreshToken} | New access and refresh token. | None (rate limited) |
/auth/logout | POST | {refreshToken} (optional) | End that session, or the caller's. Returns 204. | None |
/auth/media-token | POST | {token, expiresIn} | Admin, User, Pass | |
/auth/register | POST | {inviteCode, username, password, deviceName} | Create an account from an invite and sign this device in. | None (rate limited) |
/auth/device-link | POST | One-time code to sign in another device: {id, code, expiresAt}. Valid 2 minutes. | Admin, User, Pass | |
/auth/device-link/redeem | POST | {code, deviceName} | Sign this device in with that code. | None |
/auth/device-link/{id} | GET | {redeemed, deviceName, expiresAt}, for the device showing the code. | Admin, User, Pass | |
/auth/invite | GET | Create an invite code (?expireMinutes=, up to 30 days). | Admin | |
/auth/check | GET | 200 if the access token is valid. | Admin, User, Pass | |
/api/users/password | PATCH | {currentPassword, newPassword} | Change your password. Other devices are signed out; returns a fresh accessToken for this one. | Admin, User, Pass |
/api/users/sessions | GET | Your signed-in devices (admins: ?userId= for anyone's). | Admin, User, Pass | |
/api/users/sessions/revoke | POST | {sessionId} | Sign a device out. Returns 204. | Admin, User, Pass |
Token responses look like {accessToken, refreshToken, expiresIn, sessionId, user: {id, username, role}}.
Sign in
POST /auth/token
Authorization: Basic am9obmRvZTpzZWNyZXQ=
Content-Type: application/json
{"deviceName": "Galia on DESKTOP"}
401 means the username or password is wrong. After 5 wrong passwords for one username from one address, the server
answers 429 with Retry-After (15 seconds, doubling up to 15 minutes).
Invites
An admin creates a code with auth/invite (or from MelonCLI / MelonGUI) and shares it with the server
address, for example as https://your-server/auth/join?code=<code>. Galia reads that link from a QR code
or paste. The new user calls auth/register, which checks the code, creates the account and signs the device
in. Each code works once.
Sign in another device
A signed-in device calls auth/device-link and shows https://your-server/auth/link?code=<code>
as a QR code. The new device calls auth/device-link/redeem. The code holds no password, works once and
expires after 2 minutes.
Opening /auth/join or /auth/link in a browser shows a short page explaining what to do in the app.