Help needed to test Spotify plugin with Oauth

UPDATE
Good news folks! Finally we managed to fix the Spotify plugin (and to revamp it a little…).
We implemented a cloud routine in Volumio which allows to execute OAUTH Authentication, and implemented this user flow in Volumio’s UI and Spotify plugin.
So, starting from version 2.0.0 (released today) no more tricks are required to access the library in full.
So, just install the plugin, follow the instructions and enjoy.

Thanks to Skirkwood, which lead the way to use Oauth and improved the plugin a lot, wihtout him this would not have been possible.

PS: To use Oauth functionality, Volumio version 2.671 is requred.

Hi All, Spotify shut off access to the “My Playlists” feature of (the deprecated) Libspotify last week. I’m experimenting to see if we can replace that feature with the new (and supported) Spotify Web API. Good news is it appears to work!

So to get this working you need to authenticate your Spotify account and get back a token that the Volumio can then use in API calls to access your personal playlists. Good news is the old Libspotify library appears to still work for audio playback, as there is no replacement yet.

So I could use some help testing the Proof of Concept I created. Here’s what you need to do:

[edit: this post is now deprecated. Please view a more recent post in this thread for updated instructions.]
My Playlists.jpg

First three people who help me test this will get first dibs on the v2 version under development - which has “My Albums”, “My Tracks” and “My Artists” - and yes, they are already working!
spotify.jpg

Hi,

Tested. It is working like a charm.

One imitation (probably due to a pagination feature in Spotify API), I can see only the first 100 songs of a playlist. the additional songs are not retrieved.

Cheers,

Pierre.

Sorry to report that nothing showing in ‘My Playlists.’

Pretty sure that I followed you instructions correctly, & no errors thrown in console (journalctl). The rest of Spotify in spop seems to work fine. Anything you want checking?

Not working for me… I used a windows tool called “winscp” to see if I placed the corrected file on my raspberry pi and it is there but “My playlists” is not working.

Yeah, also not working for me. Instead of copying files around I cloned the plugins repo to my local machine, made the change there and verified the change made it over to my pi:

skynet plugins/music_service/spotify$ git br
  master
* oauth
skynet plugins/music_service/spotify$ git status
On branch oauth
Your branch is up-to-date with 'origin/oauth'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   index.js

no changes added to commit (use "git add" and/or "git commit -a")
skynet plugins/music_service/spotify$ ssh volumio@victor 'grep -A3 "Refresh token below" /data/plugins/music_service/spop/index.js'
volumio@victor's password: 
X11 forwarding request failed on channel 0
        // Plug in your Spotify Refresh token below - not the access token - the refresh token!

        var refreshToken = '<actual refresh token removed but verified to be the same as the one on the page at http://54.86.144.136:8888/';

skynet plugins/music_service/spotify$

Still the same behaviour as before, though, nothing happening when I select My Playlists, but the others (Featured etc.) seem fine. Anything I can do to help debug this on my side?

Quick follow-up. I uninstalled my existing spop plugin with the Volumio UI, rebooted, re-installed and copied over the index.js file again. Now I’m seeing this in my logs when I attempt to re-enter my account information:

2018-06-01T15:23:26.961Z - info: CALLMETHOD: music_service spop saveSpotifyAccount [object Object] 2018-06-01T15:23:26.970Z - info: CoreCommandRouter::executeOnPlugin: spop , saveSpotifyAccount 2018-06-01T15:23:27.452Z - info: mDNS: Found device james-Volumio 2018-06-01T15:23:27.888Z - info: SpopD Daemon Started 2018-06-01T15:23:32.898Z - info: Connecting to daemon 2018-06-01T15:23:32.955Z - info: CoreCommandRouter::volumioAddToBrowseSources[object Object] 2018-06-01T15:23:32.966Z - info: [1527866612959] CoreMusicLibrary::Adding element Spotify 2018-06-01T15:23:33.025Z - info: FIRST BRANCH 2018-06-01T15:23:33.350Z - info: Spotify credentials grant failed with WebapiError: Bad Request

I then went back to the unmodified plugin and I’m able to log back in to my account successfully (though obviously without access to My Playlists). FWIW, I did try with the previous token and a newly created one from 54.86.144.136:8888

Hmmm, looks like my first release is working for 1/4 people. It continues to work across all 3 of my Volumio systems today. Let me try to follow my own instructions on one of my Pi’s and see if I can find what the issue is.

For those of you who tried it and did not get it working, can you post your /var/log/volumio.log file. I can see for one person the actual Spotify credentials grant failed, so that’s progress.

Okay, going back to try to start from a clean slate, so I uninstalled the Spotify (spop) plugin, rebooted, then installed it and configured it with my account details. So I’m starting from a pristine plugin that lets me log in and view the Featured, etc. items but not my playlists.

That log is here: pastebin.com/1USpndRi

Then I went back to pastebin.com/VmF6nVhs

Then I rebooted the pi again and verified the index.js still had the correct token. After that, the volumio.log shows from boot until I click on the ‘My Playlists’ item. No error this time, it seems, but also no success on showing the page. And interestingly maybe, the error I saw before is gone when I went back to reconfigure the Spotify plugin with my username and password again. That was fine this time. So I don’t know what happened in the middle there. That log is here: pastebin.com/d1kccmAT

One last thing, though, when I was looking at the code I noticed there was a mix of tabs and spaces in the newly added stuff. It doesn’t seem to impact anything here, but I cleaned that up anyway: pastebin.com/agE1T8cv

/var/log/volumio.log @ pastebin.com/Qciv5XAK

Thanks for uploading that. Odd, you were able to successfully get a new access token:

2018-06-01T17:58:31.171Z - info: New access token = BQBHGQM5e4AXQH9FAxNZQ8Mdl1Vehrjz4aOBZ-_m_l-ey96pc_OKQZjUqoIBnAAXWyVWrYYE0MccnQoKkypxLWhB42rtplkwIsM6-QGCC-7Wql1oQeGu7F3TBC57kPL…
2018-06-01T17:58:31.173Z - info: Spotify credentials grant success

I’ll play around this afternoon. The strange this is I copied the updated index.js file to three of my Pi’s and it’s working on all of them, so there must be some kind of configuration issue I’m missing.

Glad it worked for you Pierre, everybody else has had problems to date. Here’s a new version of the plugin’s index.js file:

github.com/skikirkwood/volumio- … y/index.js

I’ve added support to browse your saved albums, tracks and favorite artists. You will want to grab a new refresh token as the API requests behind these require additional permissions from Spotify.

No idea if this is helpful or not, but I grabbed the version that enables albums/artists/tracks and those all work for me. Still no joy on the ‘My Playlists’ option and the logs are not terribly illuminating:

2018-06-01T22:50:46.971Z - info: Spotify credentials grant success
2018-06-01T22:50:50.041Z - info: CoreCommandRouter::volumioGetState
2018-06-01T22:50:50.048Z - info: CoreStateMachine::getState
2018-06-01T22:50:50.055Z - info: CorePlayQueue::getTrack 0
2018-06-01T22:50:50.307Z - info: CoreCommandRouter::executeOnPlugin: multiroom , getMultiroom
2018-06-01T22:50:50.322Z - info: Listing playlists
2018-06-01T22:50:50.333Z - info: CoreCommandRouter::volumioGetQueue
2018-06-01T22:50:50.342Z - info: CoreStateMachine::getQueue
2018-06-01T22:50:50.350Z - info: CorePlayQueue::getQueue
2018-06-01T22:50:50.361Z - info: CoreCommandRouter::volumioGetBrowseSources
2018-06-01T22:51:26.402Z - info: CoreCommandRouter::executeOnPlugin: spop , handleBrowseUri
2018-06-01T22:51:29.313Z - info: CoreCommandRouter::executeOnPlugin: spop , handleBrowseUri
2018-06-01T22:51:32.879Z - info: CoreCommandRouter::executeOnPlugin: spop , handleBrowseUri
2018-06-01T22:51:34.881Z - info: CoreCommandRouter::executeOnPlugin: spop , handleBrowseUri
2018-06-01T22:51:42.437Z - info: CoreCommandRouter::executeOnPlugin: spop , handleBrowseUri
2018-06-01T22:51:45.160Z - info: CoreCommandRouter::executeOnPlugin: spop , handleBrowseUri
2018-06-01T22:51:46.522Z - info: CoreCommandRouter::executeOnPlugin: spop , handleBrowseUri
2018-06-01T22:51:50.002Z - info: CoreCommandRouter::executeOnPlugin: spop , handleBrowseUri
2018-06-01T22:51:51.819Z - info: CoreCommandRouter::executeOnPlugin: spop , handleBrowseUri
2018-06-01T22:51:57.765Z - info: CoreCommandRouter::executeOnPlugin: spop , handleBrowseUri
2018-06-01T22:51:59.756Z - info: CoreCommandRouter::executeOnPlugin: spop , handleBrowseUri

Anything else I can offer that might help, I’m happy to try it out.

Thanks Joe. I’m still stumped why only 1/4 testers got the new plugin working. I just added a bunch of new features and it’s working great on all 3 of my Pi’s. Next step is I’ll uninstall the plugin, reinstall, then copy over the new index.js file and see what happens there.

Still no clue why 3/4 testers had trouble here, but in the mean time, we have new features! Added “My Saved Albums”, “My Saved Tracks”, “My Top Artists”, “My Top Tracks” and “My Recently Played Tracks”. These views make Spotify much more fun to play with on Volumio.

Newest version is here: github.com/skikirkwood/volumio- … ce/spotify

For the one person who got the previous version working, you’ll have to get a new refresh token that has the scopes for the new permissions needed.

Now on to figuring out why it’s not working for others…
spotify2.png

I wonder if it’s an account related thing. I have a Premium for Family account. My account (the one I’m using on Victor, my Volumio install) is the owner but there are four other active accounts, one for each of the family members. Another possibility is we have a few collaborative playlists shared between our accounts. So maybe there’s some unexpected atom coming back in the results when you make your API call.

Don’t know, just throwing out ideas there and suggesting ways my account may be different than yours.

Hey Joe, can you try this. Get a new refresh token here:

54.86.144.136:8888/

Then copy this file into /data/plugins/music_service/spop:

github.com/skikirkwood/volumio- … y/index.js

And paste in your new refresh token. After you do that, let me know if any of the new views worked - there’s a bunch of them. And after doing that upload your log file.

I used to have a family account but reverted to a single user premium account. I just uninstalled the Spotify plugin one one of my Pi’s, reinstalled it, then copied the new Spotify index.js file over and everything is working. So perhaps it is the type of account.

Okay, so I gave that a shot. Got a new token, rebooted and things are somewhat better now, I think. I still don’t have access to my playlists, I click on that option and nothing happens, but all of the others work for me now (you can probably see in the log I rifled through all of the options the played a song out of my recently played list).

I pasted the log at pastebin.com/5VvtwQ5q

So, I guess there’s two possibly distinct things to test here. If it is the family versus single premium account, it sounds like I or someone else with a family membership will have to be more involved in looking at the root cause. But the other possibility is maybe it’s just the presence of collaborative playlists in the ‘my playlist’ set. If you don’t have any collaborative lists in your setup, that might explain the difference. I know in both the desktop and mobile UIs the collaborative lists get decorated differently. So if you think that’s maybe an option worth investigating, I’ve made this playlist open.spotify.com/user/joeythesa … MwifBJkQKg and specifically flagged it as collaborative. So even though I created it you should be able to edit it. Might be worth checking quickly if you can add it to your playlists and see if the option starts failing for you as well.

Anwyay, I’ll be checking in occasionally this weekend, so if there’s other stuff to try out, I’ll be happy to give it a shot.

Thanks.

WORKING ! FANTASTIC ! THANX !!

Config Odroid C2 / volumio 2.344 / spop version : “My Saved Albums”, “My Saved Tracks”, “My Top Artists”, “My Top Tracks” and “My Recently Played Tracks”. / spotify familly account

Visible :

20 items from : My Playlists

50 items from : My saved Albums, My Saved Tracks, My Top Arstists, My Top Tracks …

100 songs from any playlists

Trying to find a common factor here … I have a premium family account, but no collaborative playlists.