<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic invalid_client on api/token call in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/invalid-client-on-api-token-call/m-p/5471438#M7329</link>
    <description>&lt;P&gt;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:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;@FeignClient(value = "spotifyAccountService", url = "&lt;A href="https://accounts.spotify.com" target="_blank" rel="noopener"&gt;https://accounts.spotify.com&lt;/A&gt;")&lt;BR /&gt;public interface SpotifyAccountService&lt;BR /&gt;{&lt;BR /&gt;public static final String GRANT_TYPE = "client_credentials";&lt;/P&gt;&lt;P&gt;@PostMapping(value = "/api/token", //&lt;BR /&gt;headers = "Content-Type=application/x-www-form-urlencoded")&lt;BR /&gt;public AccessToken getToken(&lt;BR /&gt;@RequestHeader(name = "Authorization") String authorization,&lt;BR /&gt;@RequestBody String grantType);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The call in my REST controller looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;private AccessToken getAccessToken()&lt;BR /&gt;{&lt;BR /&gt;if (this.accessToken == null)&lt;BR /&gt;{&lt;BR /&gt;String payload = this.clientID + ":" + this.clientSecret;&lt;BR /&gt;String authorization = "Basic " + Base64.getEncoder().encodeToString(payload.getBytes());&lt;/P&gt;&lt;P&gt;this.accessToken = this.spotifyAccountService.getToken(authorization,&lt;BR /&gt;"grant_type=" + SpotifyAccountService.GRANT_TYPE);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return this.accessToken;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;</description>
    <pubDate>Sat, 10 Dec 2022 18:53:48 GMT</pubDate>
    <dc:creator>reactrax</dc:creator>
    <dc:date>2022-12-10T18:53:48Z</dc:date>
    <item>
      <title>invalid_client on api/token call</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/invalid-client-on-api-token-call/m-p/5471438#M7329</link>
      <description>&lt;P&gt;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:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;@FeignClient(value = "spotifyAccountService", url = "&lt;A href="https://accounts.spotify.com" target="_blank" rel="noopener"&gt;https://accounts.spotify.com&lt;/A&gt;")&lt;BR /&gt;public interface SpotifyAccountService&lt;BR /&gt;{&lt;BR /&gt;public static final String GRANT_TYPE = "client_credentials";&lt;/P&gt;&lt;P&gt;@PostMapping(value = "/api/token", //&lt;BR /&gt;headers = "Content-Type=application/x-www-form-urlencoded")&lt;BR /&gt;public AccessToken getToken(&lt;BR /&gt;@RequestHeader(name = "Authorization") String authorization,&lt;BR /&gt;@RequestBody String grantType);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The call in my REST controller looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;private AccessToken getAccessToken()&lt;BR /&gt;{&lt;BR /&gt;if (this.accessToken == null)&lt;BR /&gt;{&lt;BR /&gt;String payload = this.clientID + ":" + this.clientSecret;&lt;BR /&gt;String authorization = "Basic " + Base64.getEncoder().encodeToString(payload.getBytes());&lt;/P&gt;&lt;P&gt;this.accessToken = this.spotifyAccountService.getToken(authorization,&lt;BR /&gt;"grant_type=" + SpotifyAccountService.GRANT_TYPE);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return this.accessToken;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Dec 2022 18:53:48 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/invalid-client-on-api-token-call/m-p/5471438#M7329</guid>
      <dc:creator>reactrax</dc:creator>
      <dc:date>2022-12-10T18:53:48Z</dc:date>
    </item>
  </channel>
</rss>

