From 69c30768996d5e0ea45610e50e9fa0e55b72857a Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sat, 28 May 2022 14:19:20 +0200 Subject: [PATCH] Auto refresh spotify access token when expired --- deemix/plugins/spotify.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deemix/plugins/spotify.js b/deemix/plugins/spotify.js index 93c85cc..5e5ab7d 100644 --- a/deemix/plugins/spotify.js +++ b/deemix/plugins/spotify.js @@ -426,6 +426,10 @@ class Spotify extends Plugin { this.sp.clientCredentialsGrant().then( (creds)=>{ this.sp.setAccessToken(creds.body.access_token) + // Need to get a new access_token when it expires + setTimeout(()=>{ + this.checkCredentials() + }, creds.body.expires_in*1000-10) this.enabled = true }, ()=>{