[Discussion] Streaming API - Simple Oauth2 process


I have started to investigate how to by example integrate Deezer Music Streaming API with Volumio but the Oauth2 process is complex and will request through a popup window that you confirm/authorize the access for Volumio to your Deezer account.

That means that we can’t automate completely the process using an user/pwd to get your playlists, … as we can do with the Volumio’s spotify plugins if you use a premium account.

Question : Is there a better web music streaming API, which is not yet implemented and that we could use as new Volumio plugin without the need to have a paying account and where the Oauth2 process could be automated completely ?

Best regards


The new Spotify Web API requires authentication with Oauth2 - user/pwd is no longer supported. So as a stopgap measure we put up a “micro” size EC2 server on AWS on their free tier and run a Node.js application that handles the Spotify authentication. The end result is you get a refresh token that can be used to access Spotify. Some contributors are now adding the refresh token field to the Spotify plugin credentials screen to make it easier to access this.

There’s certainly better ways to do this, but if Deezer has sample code for the Oauth authentication similar to what Spotify provides then it’s a quick way to get started. I followed this guide for the above work:

developer.spotify.com/documenta … ick-start/

Following skikirkwood’s progress on the spotify plugin oauth flow, I think its about time to have an official Oauth service for volumio to streamline the addition of new services with a simple API that plugin developers can use.

Idea is to leverage the MyVolumio cloud platform, and offer this to myvolumio users (including free tiers ones).

@skikirkwood what about re-starting this idea that we had since long time?

Many thanks for the info Michelangelo :wink:

The Spotify Web API also requires (see step 4. Click Log in link; the Spotify Accounts login appears.) that you pass your credential using the popup window (as we must also do for Deezer).

So, how can you get rid of this step using your nodejs spotify proxy deployed on Amazon EC2 ? Have you been able to automate completely this step without the need to pass the info using the UI Screen ? Did you get a permanent token = which never expires from spotify and that the volumio spotify plugin can use ?

Remark : What you describe here will only work for users having a spotify premium account 1

Hi there, unfortunately I don’t have time right now to contribute further to Volumio.

We have not completely automated the step of getting a Spotify Oauth2 token. The Node.js app running on AWS generates two tokens - an access token which expires after an hour, and a refresh token - which never expires. So after the refresh token is copied over to your Volumio system the Spotify plugin uses it to get a new access token, and all API calls check to see if the access token is expired, and if so, uses the refresh token to generate a new access token.

I will have investigate the code source of this python project where we can get the playlists of a user using only the client_id, client_secret of the app created on Spotify

import spotipy
from spotipy.oauth2 import SpotifyClientCredentials

client_id = "my_client_id"
client_secret = "my_secret_id"
spotify_user_id = spotify_user_id # integer number of x chars

client_credentials_manager = SpotifyClientCredentials(client_id, client_secret)
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)

def show_tracks(tracks):
    for i, item in enumerate(tracks['items']):
        track = item['track']
        print ("   %d %32.32s %s" % (i, track['artists'][0]['name'],

playlists = sp.user_playlists(spotify_user_id)
while playlists:
    for i, playlist in enumerate(playlists['items']):
        if playlist['owner']['id'] == str(spotify_user_id):
            print (playlist['name'])
            print ('  total tracks', playlist['tracks']['total'])
            results = sp.user_playlist(spotify_user_id, playlist['id'],fields="tracks,next")
            tracks = results['tracks']
            while tracks['next']:
                tracks = sp.next(tracks)

Remark: Concerning Deezer, we could also follow the approach of spotify to get a authToken but as this token expires, then we will been also faced to the same issue that we have for spotify where you must be authenticated using a popup window - see : developers.deezer.com/api/oauth