Sonos controller for your web browser
Merge variety of fixes and update dependencies to node=16
Unfortunately, there is a limitation to the Spotify authorization. You must authorize Spotify from the machine that the Sonos Web server is running on. You must authorize Spotify from localhost:5050 and not, for example, 192.168.0.16:5050. The reason for this is that the Spotify API requires the redirect URL be defined in the Spotify Developer Dashboard and since I cannot add a wildcard route, the only allowable redirect URL is localhost:5050.
Once Spotify is authorized from the machine the Sonos Web server is running on, you may then access Spotify from a different machine and use it without issue.
You won’t be able to connect Spotify on the headless machine due the lack of being able to access a web browser and authorize. However, the easiest way to get it to work (for now) is to install Sonos Web on a desktop/laptop and then authorize Spotify in your web browser. Once authorized, the tokens are cached in the browser. You must then copy the localStorage
spotify settings to the browser where your headless install is running. After that you will be able to use Spotify on Sonos Web from your headlesss machine.
// Open up developer tools console on localhost:5050
// Authorize Spotify, and then proceed with below:
var settings = JSON.parse(localStorage.settings)
settings.spotify
// copy the output of the above command to you clipboard
// should look something like this
{refreshToken: "yourLongStreamOfCharactersRefreshTokenIdHere"}
// Open up developer tools on your remote/headless machine ex. 192.168.0.200:5050
// run the following code in the console
var settings = JSON.parse(localStorage.settings)
// paste what you copied earlier from your clipboard to after the equals sign
settings.spotify = {refreshToken: "yourLongStreamOfCharactersRefreshTokenIdHere"}
localStorage.setItem('settings', JSON.stringify(settings))
After this, accessing Spotify on your headless machine should work properly.