Spotify "Error 400" when refreshing with AJAX

Viewed 22

I am using the following code to make a POST request to https://accounts.spotify.com/api/token in order to receive a refreshed access token although every time I've tried I get an Error 400 (Bad Request)

$.ajax({
    url: 'https://accounts.spotify.com/api/token',
    type: 'post',
    Headers: { 
        'Authorization': 'Basic ' + btoa(ClientID ':' ClientSecret),
        'Content-Type': 'application/x-www-form-urlencoded'},
    body: {
        grant_type: 'refreshtoken',
        refresh_token: RefreshToken
    },
    json: true
});
0 Answers
Related