Announcements

Help Wizard

Step 1

NEXT STEP

invalid_client on api/token call

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?

Reply
0 Replies

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random