invalid_client on api/token call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page