FinianLandes / SpotifyEsp32

This is a library to connect to and control spotify from an esp
GNU Affero General Public License v3.0
14 stars 4 forks source link

Trying to get currently playing either crashes the ESP32 or returns "Something went wrong" #13

Closed krnlexception closed 2 months ago

krnlexception commented 3 months ago

Trying to get currently playing library crashes the whole device, with log:

18:36:59.284 -> -54
18:36:59.947 -> HTTP/1.1 400 Bad Request
18:36:59.947 -> content-type: application/json
18:36:59.947 -> Content-Length: 99
18:36:59.947 -> Filter: Off
18:36:59.947 -> GET "me/player/currently-playing" Status: 400
18:36:59.947 -> Reply: {"error":{"status":400,"message":"Only valid bearer authentication supported"}}
18:37:00.543 -> HTTP/1.1 400 Bad Request
18:37:00.543 -> content-type: application/json
18:37:00.543 -> Content-Length: 69
18:37:00.576 -> Filter: On

When it works, it doesn't return currently playing track or artist, even though Spotify API itself returns it.

FinianLandes commented 3 months ago

It might be that spotify changed something or something else. Im currently unavailable for 3 weeks i will get back to you as soon as i'm available again. Maybe try other endpoints to check whetherthe issue still persists

krnlexception commented 3 months ago

It might be that spotify changed something or something else. Im currently unavailable for 3 weeks i will get back to you as soon as i'm available again. Maybe try other endpoints to check whetherthe issue still persists

Play/pause and next endpoints work fine, just currently playing doesn't.

FinianLandes commented 3 months ago

Then it might be related to the request type as next/play are post/put and currently playing is get but as mentioned i dont have access to a pc in the next two weeks so cant change anything but will do asap

FinianLandes commented 2 months ago

Hows your status on this? as it works just fine for me... do you have your code by any chance? Also by looking at your screenshot it seems that there is an issue with the auth are you sure you have the right permissions? when lookig at the logs the first request to an endpoint will fail but the library then automatically gets the access token and retries the requests. this looks log wise like this: Connected to WiFi Authenticated HTTP/1.1 400 Bad Request content-type: application/json Content-Length: 99 Filter: On GET "me/player/currently-playing" Status: 400 Reply: {"error":{"status":400,"message":"Only valid bearer authentication supported"}} HTTP/1.1 200 OK content-type: application/json Content-Length: 808 Filter: On POST "acces token" Status: 200 Reply: {"access_token":"BQAOdJFVOu75oNPaxxfeWNAp8S72wlct1wOM6OIl3IIn__S80Lr8V6nbcdt_fJv7o2Ro_HG84oR6CtT_tL8nVHhI5bFwMpFTX3C7deVjW-jBtIFbuoaYbnWdjlkUP80hoOPzuymuso12BOGXGxoR41IWRWweQqgzwiP6SHDl-9BQU1KhoBJ5cimYl6byYBC72P2B8lHLKkbAIYQX2TeMcyBZPMobde6O0PW4bqL_wN9Fz8AyyklEFuXAygwRzjlUMeR90ANxkRmLyZUjLiQpo_rCQ7ukpWcVdZ0S_IamHGNS5aaQ8tHonHKvlpxflHX-Jl8NMpI2Fo5NBpU_YANv"} HTTP/1.1 200 OK content-type: application/json; charset=utf-8 Content-Length: 5193 Filter: On GET "me/player/currently-playing" Status: 200 Reply: {"progress_ms":141564}

krnlexception commented 2 months ago

Hows your status on this? as it works just fine for me... do you have your code by any chance? Also by looking at your screenshot it seems that there is an issue with the auth are you sure you have the right permissions? when lookig at the logs the first request to an endpoint will fail but the library then automatically gets the access token and retries the requests. this looks log wise like this: Connected to WiFi Authenticated HTTP/1.1 400 Bad Request content-type: application/json Content-Length: 99 Filter: On GET "me/player/currently-playing" Status: 400 Reply: {"error":{"status":400,"message":"Only valid bearer authentication supported"}} HTTP/1.1 200 OK content-type: application/json Content-Length: 808 Filter: On POST "acces token" Status: 200 Reply: {"access_token":"BQAOdJFVOu75oNPaxxfeWNAp8S72wlct1wOM6OIl3IIn__S80Lr8V6nbcdt_fJv7o2Ro_HG84oR6CtT_tL8nVHhI5bFwMpFTX3C7deVjW-jBtIFbuoaYbnWdjlkUP80hoOPzuymuso12BOGXGxoR41IWRWweQqgzwiP6SHDl-9BQU1KhoBJ5cimYl6byYBC72P2B8lHLKkbAIYQX2TeMcyBZPMobde6O0PW4bqL_wN9Fz8AyyklEFuXAygwRzjlUMeR90ANxkRmLyZUjLiQpo_rCQ7ukpWcVdZ0S_IamHGNS5aaQ8tHonHKvlpxflHX-Jl8NMpI2Fo5NBpU_YANv"} HTTP/1.1 200 OK content-type: application/json; charset=utf-8 Content-Length: 5193 Filter: On GET "me/player/currently-playing" Status: 200 Reply: {"progress_ms":141564}

Yes, I still have the project. Permissions are set correctly in Spotify dashboard.

FinianLandes commented 2 months ago

thats weird. are you using PIO or Arduino IDE? If you want you can send me the project on discord or here so i can test it myself or on discord we can also just go over it with screensaring, whatever you like best

krnlexception commented 2 months ago

I use Arduino IDE, and yes, I can send over the project (just with API keys etc. cut out). My Discord username is nolemretaw.

krnlexception commented 2 months ago

Update: I've copied some code from this projects source code to bypass JSON filter and use raw JSON response for currently playing (that my project was already getting to determine track position and length), and current artist(s) and track name work perfectly fine.

FinianLandes commented 2 months ago

If thats ok ill close the issue but you can still send me the code on dc and ill look over it and try to fix it. Also if you dont pass a filter as arg you should get the complete json response.