Auto refresh spotify access token when expired

This commit is contained in:
RemixDev 2022-05-28 14:19:20 +02:00
parent faec1c1a02
commit 69c3076899
No known key found for this signature in database
GPG key ID: B33962B465BDB51C

View file

@ -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
},
()=>{