Files
Bose-SoundTouch/docs/analysis/MISSING-ROUTES-SPOTIFY.md
T
aa7b2c28ab feat: improve Bose SoundTouch parity, Spotify integration, and data reliability (#138)
feat: improve Bose SoundTouch parity, Spotify integration, and data
reliability

- Update XML marshaling for ServicePreset and ServiceRecent to match
Bose parity requirements.
- Add support for adding music sources via
`/streaming/account/{account}/source`.
- Implement HandleBoseAccountToken for Spotify OAuth code exchange and
token persistence.
- Implement atomic file writes in the datastore to prevent data
corruption.
- Add startup logic to initialize default sources for existing devices.
- Expand test coverage with new parity regression and Spotify
integration tests.

---------

Co-authored-by: Junie <junie@jetbrains.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-04-01 21:55:52 +02:00

2.6 KiB

Spotify Account Addition Implementation Status

To fully replace Bose cloud services for the Spotify account addition flow in the "Stockholm" SoundTouch application, the following routes have been implemented in the soundtouch-service:

1. OAuth Token Exchange (Bose Cloud)

The Stockholm background worker (in worker_common.js and spotify_worker.js) performs a token exchange using an authorization code.

  • Route: POST /oauth/account/{account}/music/musicprovider/{sourceID}/token/cs
  • Purpose: To exchange the Spotify authorization code for a Bose-mediated token.
  • Implementation: HandleBoseAccountToken in pkg/service/handlers/handlers_oauth.go.
  • Registration: Registered in cmd/soundtouch-service/main.go under the /oauth route group.

2. Cloud Source Registration (Marge Service)

The SoundTouch application registers a new music source (e.g., Spotify) with the Bose cloud profile.

  • Route: POST /streaming/account/{account}/source
  • Purpose: To add the new source (username, credentials, display name) to the user's emulated cloud profile.
  • Implementation: HandleMargeAddSource in pkg/service/handlers/handlers_marge.go.
  • Registration: Registered in cmd/soundtouch-service/main.go under the /streaming route group.
  • Payload Format: XML application/vnd.bose.streaming-v1.1+xml containing <source> with <username>, <sourceproviderid>, and <credential type="token_version_3">.

3. Redirect Handling (Browser to App)

The soundtouch:// deep link redirect URI is handled by the management interface which provides the OAuth callback.

  • Callback Route: GET /mgmt/spotify/callback
  • Implementation: HandleMgmtSpotifyCallback in pkg/service/handlers/handlers_mgmt.go.
  • Confirmation Route: POST /mgmt/spotify/confirm (used by mobile apps for deep-link codes).
  • Implementation: HandleMgmtSpotifyConfirm in pkg/service/handlers/handlers_mgmt.go.

Implementation Details

  1. Marge Add Source:

    • HandleMargeAddSource in pkg/service/handlers/handlers_marge.go parses the incoming XML and persists the new source to the DataStore for the corresponding account.
  2. OAuth Account Token Exchange:

    • HandleBoseAccountToken in pkg/service/handlers/handlers_oauth.go supports the /oauth/account/.../token/cs path.
    • It responds with a JSON payload including access_token and token_type "Bearer" after exchanging the code via ExchangeCodeAndStore.
  3. Router Registration:

    • These paths are registered in cmd/soundtouch-service/main.go within the /streaming, /oauth, and /mgmt route blocks.