in src/auth/AccessTokenHelpers.ts [22:42]
private static async refreshToken(clientId: string, refreshToken: string): Promise<AccessToken> {
const params = new URLSearchParams();
params.append("client_id", clientId);
params.append("grant_type", "refresh_token");
params.append("refresh_token", refreshToken);
const result = await fetch("https://accounts.spotify.com/api/token", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: params
});
const text = await result.text();
if (!result.ok) {
throw new Error(`Failed to refresh token: ${result.statusText}, ${text}`);
}
const json: AccessToken = JSON.parse(text);
return json;
}