CrunchyFlakes
CrunchyFlakes

Reputation: 15

Spotify Web Api Token Request Response 400

Right now I'm trying to exchange my authorization code to a token over the Authorization Code Flow method in the Spotify Web Api, but as Response I always get a 400 Status. Here's the code I'm using:

HttpPost httppost = new HttpPost(new URI("https://accounts.spotify.com/api/token/?grant_type=authorization_code&code=" + tempCode + "&redirect_uri=" + RedirectUri));
    httppost.addHeader("Authorization",  "Basic " + Base64.encodeBase64String((ClientId + ":" + ClientSecret).getBytes()));
    httppost.setProtocolVersion(HttpVersion.HTTP_1_1);

Thank you for helping me!

Upvotes: 1

Views: 595

Answers (1)

Jean-Michel Provencher
Jean-Michel Provencher

Reputation: 735

Remove the slash after token

it should be https://accounts.spotify.com/api/token

Also, the request parameters should be in the POST body instead of being in the URI.

Upvotes: 1

Related Questions