sonos

How do I retrieve the catalog of a music service?


I am building an app that integrates nicely with Sonos speakers. I would like to provide the user the ability to select the container (playlist/stations/...leafs of the tree here) of the music service provider. Say Amazon or Spotify...

I managed to understand the vast majority of the SOAP calls however, I could not figure out how to query the user's selected service (devicelink) and provide the same list that the Sonos controller show.

How do I do that?

thanks!


Solution

  • Sonos decided that access to music services should no longer be allowed by third-party-apps some time ago.

    I figured out how it works and made a complete walkthrough here, https://Sonos.svrooij.io/music-services.html

    It makes a second connection to the specific music service, just for browsing the catalog.

    1. get some data from the Sonos device
    2. Request an auth code for the service
    3. Let the user login
    4. If the user responded, request an access token and a refresh token.
    5. Save these tokens in your Sonos system (optional)
    6. Use the tokens to talk to the music service
    7. Save and use the new access token if it is expired (optional)

    You can also use my sonos-ts library, which has support for music services that require authentication.