Plugin: rework login/status/logout + config #14

Closed
opened 2026-08-09 20:31:47 +00:00 by hermes · 1 comment
Owner

Context

Plugin rework (see #18). The command surface stays (beet apple login / status / logout / sync / isrc-backfill / isrc-submit) but auth now talks
to the gateway.

Task

In /opt/data/git/git.sams.wtf/coop/beets-appleplaylists:

  • Config defaults become service_url: "" and service_token: "" (env
    fallbacks APPLE_MUSIC_SERVICE_URL / APPLE_MUSIC_SERVICE_TOKEN);
    remove team_id, key_id, key_path, services_id, redirect_uri,
    credentials.
  • beet apple login: print and open {service_url}/login, then poll
    GET /api/v1/status every ~2 s (up to ~120 s) until logged_in is true;
    report success with the token's updated_at.
  • beet apple status: GET /api/v1/status; print "logged in (since ...)"
    or "not logged in — visit {service_url}/login".
  • beet apple logout: DELETE /api/v1/login; print the result.
  • _sync and _backfill: replace the AppleAuthManager credentials dance
    with the AppleAPIClient(service_url, service_token) from #13; a missing
    config raises a ui.UserError naming the missing setting.
  • _submit (MusicBrainz) is untouched.

Acceptance criteria

  • Commands work against a mocked gateway (FakeSession): login polls until
    logged in, status reflects the store, logout calls DELETE.
  • Missing service_url produces a clear error, not a traceback.
  • uv run pytest green.
## Context Plugin rework (see #18). The command surface stays (`beet apple login / status / logout / sync / isrc-backfill / isrc-submit`) but auth now talks to the gateway. ## Task In `/opt/data/git/git.sams.wtf/coop/beets-appleplaylists`: - Config defaults become `service_url: ""` and `service_token: ""` (env fallbacks `APPLE_MUSIC_SERVICE_URL` / `APPLE_MUSIC_SERVICE_TOKEN`); remove `team_id`, `key_id`, `key_path`, `services_id`, `redirect_uri`, `credentials`. - `beet apple login`: print and open `{service_url}/login`, then poll `GET /api/v1/status` every ~2 s (up to ~120 s) until `logged_in` is true; report success with the token's `updated_at`. - `beet apple status`: `GET /api/v1/status`; print "logged in (since ...)" or "not logged in — visit {service_url}/login". - `beet apple logout`: `DELETE /api/v1/login`; print the result. - `_sync` and `_backfill`: replace the `AppleAuthManager` credentials dance with the `AppleAPIClient(service_url, service_token)` from #13; a missing config raises a `ui.UserError` naming the missing setting. - `_submit` (MusicBrainz) is untouched. ## Acceptance criteria - Commands work against a mocked gateway (FakeSession): login polls until logged in, status reflects the store, logout calls DELETE. - Missing `service_url` produces a clear error, not a traceback. - `uv run pytest` green.
Author
Owner

Implemented in coop/beets-appleplaylists commit b5a121c8c728bcf218e5e4561bed603e01e82b44. The plugin now uses service_url/service_token with APPLE_MUSIC_SERVICE_URL/APPLE_MUSIC_SERVICE_TOKEN fallbacks, polls gateway status during login, reports status timestamps, clears the remote login on logout, and uses the gateway client for sync/backfill. Missing settings raise clear ui.UserError messages.

Verification: mocked login/status/logout tests pass and uv run pytest -q reports 21 passed.

Implemented in `coop/beets-appleplaylists` commit `b5a121c8c728bcf218e5e4561bed603e01e82b44`. The plugin now uses `service_url`/`service_token` with `APPLE_MUSIC_SERVICE_URL`/`APPLE_MUSIC_SERVICE_TOKEN` fallbacks, polls gateway status during login, reports status timestamps, clears the remote login on logout, and uses the gateway client for sync/backfill. Missing settings raise clear `ui.UserError` messages. Verification: mocked login/status/logout tests pass and `uv run pytest -q` reports 21 passed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
coop/beets-appleplaylists#14
No description provided.