0

I'm trying to refresh my infusionsoft token, using this guide from their documentation: https://developer.infusionsoft.com/authentication/#refresh-access-token

$url = "https://api.infusionsoft.com/token";
$client_id = '';
$client_secret = '';
$refresh_token = '';

$options = array(
'http' => array(
    'header'  => "Content-type: application/json\r\n".
        "Authorization: Basic ". base64_encode($client_id. ":". $client_secret),
    'grant_type' => 'refresh_token',
    'refresh_token' => $refresh_token,
    'method'  => 'POST',
  )
);

Does anything jump out at you? I am also reaching out for help on Infusionsoft forums as well, but I was wondering if any of you have done this before.

poolfork
  • 22
  • 5

1 Answers1

1

grant_type and other variables need to be send as post parameter, you are currently sending them as http headers.

Also done here: How to post data in PHP using file_get_contents?

BlackNetworkBit
  • 776
  • 10
  • 21
  • This didn't fix the issue, but thanks for pointing me down the right track. i now have: $jstr = array( 'grant_type' => 'refresh_token', 'refresh_token' => $refresh_token, ); $options = array( 'http' => array( 'header' => "Content-Type: application/json\r\n" . "Authorization: Basic ". base64_encode($client_id. ":". $client_secret), 'method' => 'POST', 'content' => json_encode($jstr) ) ); I have a feeling the "Authorization:" tag is incorrect – poolfork Sep 12 '18 at 16:57
  • 1
    well, what was the error ? did the answer solved your question or not ? – BlackNetworkBit Sep 12 '18 at 16:58
  • It's a 401 unauthorized error, actually (even though I'm confident that the client ID and secret are correct) – poolfork Sep 12 '18 at 17:10