dimanche 7 octobre 2018

Spotify web SDK refresh access token

So right now, when I initialize the web SDK i do something like this

let token = this.access_token;
this.player = new Spotify.Player({
name: 'Soundseek.io',
getOAuthToken: cb => { cb(token); }
});

This all works for an hour, and then I refresh my access token and get a new token.

Now, does anybody know how I can update the oauthtoken without killing the player and reinitializing it?

Right now I do this

this.player.disconnect();
this.player = null;

and then run the previous code snippet again.

What I was hoping would work is something like (just one of these)

this.player.getOAuthToken(this.access_token);
this.player.refreshOAuthToken(this.access_token);
this.player.setOAuthToken(this.access_token);
this.player.updateOAuthToken(this.access_token);
this.player.token(this.access_token);
this.player.updateToken(this.access_token);
this.player.refresh(this.access_token);
this.player.newToken(this.access_token);
this.player.swap(this.access_token);

Just one of these.. (and these are just my guesses. none of them worked though I think)

Aucun commentaire:

Enregistrer un commentaire