Skip to content

Commit

Permalink
1.0.4 - Fixes 401 after 1h
Browse files Browse the repository at this point in the history
  • Loading branch information
mickeydarrenlau committed Jan 25, 2024
1 parent 5724410 commit 366c1ed
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
15 changes: 10 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,35 @@ export default class MyPlugin extends Plugin {
async onload() {
await this.loadSettings();
if(this.settings.spotify_access_token){

let json_spotify = this.settings.spotify_access_token
async function refreshspot(setting) {
let json_spotify = setting.spotify_access_token
console.log(json_spotify)
let refresh_token = json_spotify.refresh_token
let body = new URLSearchParams(
{
grant_type: 'refresh_token',
refresh_token: refresh_token,
client_id: this.settings.spotify_client_id
client_id: setting.spotify_client_id
}
).toString()
let access_token = await requestUrl({
"url": 'https://accounts.spotify.com/api/token',
"method": "POST",
"headers": {
'content-type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic ' + (btoa(this.settings.spotify_client_id + ':' + this.settings.spotify_client_secret))
'Authorization': 'Basic ' + (btoa(setting.spotify_client_id + ':' + setting.spotify_client_secret))
},
"body": body,
"throw": false
})
let data = await access_token.json
console.log(data)
window.spotifysdk = SpotifyApi.withAccessToken(this.settings.spotify_client_id, data);
window.spotifysdk = SpotifyApi.withAccessToken(setting.spotify_client_id, data);
}
await refreshspot(this.settings)
setInterval( async () => {
await refreshspot(this.settings)
}, "3600000")



Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"authorUrl": "https://github.com/Darren-project",
"fundingUrl": "",
"isDesktopOnly": false,
"version": "1.0.3"
"version": "1.0.4"
}
2 changes: 1 addition & 1 deletion version-bump.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFileSync, writeFileSync } from "fs";

const targetVersion = "1.0.3";
const targetVersion = "1.0.4";

// read minAppVersion from manifest.json and bump version to target version
let manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"1.0.0": "0.15.0",
"1.0.1": "0.15.0",
"1.0.2": "0.15.0",
"1.0.3": "0.15.0"
"1.0.3": "0.15.0",
"1.0.4": "0.15.0"
}

0 comments on commit 366c1ed

Please sign in to comment.