invalid_client on api/token call

I'm using the Client Credentials Flow because I'm developing a web app. It's in Java and I'm using an Open Feign interface to call the Spotify API:

@FeignClient(value = "spotifyAccountService", url = "https://accounts.spotify.com")
public interface SpotifyAccountService
{
public static final String GRANT_TYPE = "client_credentials";

@PostMapping(value = "/api/token", //
headers = "Content-Type=application/x-www-form-urlencoded")
public AccessToken getToken(
@RequestHeader(name = "Authorization") String authorization,
@RequestBody String grantType);

}

 

The call in my REST controller looks like this:

 

private AccessToken getAccessToken()
{
if (this.accessToken == null)
{
String payload = this.clientID + ":" + this.clientSecret;
String authorization = "Basic " + Base64.getEncoder().encodeToString(payload.getBytes());

this.accessToken = this.spotifyAccountService.getToken(authorization,
"grant_type=" + SpotifyAccountService.GRANT_TYPE);
}

return this.accessToken;
}

 

What am I doing wrong?

Child Item
Child Item
Child Item

Accepted answers

All comments

Child Item
Child Item