0

Per https://developer.beatsmusic.com/docs/read/getting_started/Web_Server_Applications, I'm successfully getting the authorization code. I'm then performing the below curl post request and I'm receiving a "invalid_client" error in response. Note that MY_KEY, MY_SECRET, MY_REDIRECT_URI and AUTHORIZATION_CODE are correct.

$postUrl = 'https://partner.api.beatsmusic.com/v1/oauth2/token';

$postData = array(
    'client_id' => MY_KEY, 
    'client_secret' => MY_SECRET, 
    'redirect_uri' => MY_REDIRECT_URI, 
    'grant_type' => 'authorization_code', 
    'code' => AUTHORIZATION_CODE
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $postUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

Any clue why I'm getting the error? I'm expecting to get a json response with the access and refresh tokens. Thanks in advance.

Uwe L. Korn
  • 8,080
  • 1
  • 30
  • 42
Bryan Schoen
  • 741
  • 5
  • 3

1 Answers1

0

You should sent the data with Content-Type application/x-www-form-urlencoded, the above code may produce multipart/form-data which did not work for me at least some weeks ago.

Uwe L. Korn
  • 8,080
  • 1
  • 30
  • 42