jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.84k stars 461 forks source link

Unable to authenticate Spotify with client id #653

Open normanth opened 5 years ago

normanth commented 5 years ago

Hi,

first: thank you for this great API!!

I have a problem with playing a spotify playlist (sonos-http-api@1.6.3). I connected Sonos with Spotify, created a developer account and added clientId and clientSecret to the settings.json.

{
    "port": 5015,
    "spotify": {
        "clientId": " 5e87731f2XXXXXXXXXXXXXXXXXXX",
        "clientSecret": "2dd7ab0066XXXXXXXXXXXXXX"
    }
}

If I call "http://ds.fritz.box:5015/Kueche/spotify/now/spotify:track:7sXTcibuNYugjjYNfgf2kY" evertyhing works - I get the status "success".

If I call "http://ds.fritz.box:5015/Kueche/musicsearch/spotify/playlist/Kinderlied" I get the status "error":

Unable to authenticate Spotify with client id: 5e87731f2XXXXXXXXXXXXXXXXXXX

Error: Unable to authenticate Spotify with client id:  5e87731f2XXXXXXXXXXXXXXXXXXX
    at request.then.catch (/app/lib/music_services/spotifyDef.js:94:14)
    at tryCatcher (/app/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/main/promise.js:510:31)
    at Promise._settlePromiseAt (/app/node_modules/bluebird/js/main/promise.js:584:18)
    at Promise._settlePromises (/app/node_modules/bluebird/js/main/promise.js:700:14)
    at Async._drainQueue (/app/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/app/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues (/app/node_modules/bluebird/js/main/async.js:15:14)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)

I think that's also the reason why a spotify playlist will not continue after a "say" command.

In the issues I found problems with country settings - but I don't know what to do.

I would be very happy about an idea for the solution.

Thanks, Norman

By the way: there seems to be a problem with umlauts (ä,ü,ö...) in room names.

normanth commented 5 years ago

No one idea what could be the cause?

jishi commented 5 years ago

Sorry about the late answer. The /spotify/now endpoint doesn't use the credentials (because it just references the Sonos credentials used for playback), so my assumption is that the credentials you added are wrong. I would double check that you entered them correctly, and in the right field, and maybe request new credentials just to be sure.

umlauts in room names should be fine, but the request sent must use UTF-8 in the URL. If not, use URL encoded values for it. You can use the encodeURIComponent('RoomWithÜ') in node.js or chrome web inspector console to get the correctly encoded value.