REST error using InfusionSoft API

425 views Asked by At

I am getting an error while calling the InfusionSoft REST API and am at a loss as to the reason.

My CLIENT_ID is the 24 character "Key" as shown in https://keys.developer.infusionsoft.com/apps/myapps. The CLIENT_SECRET is a shorter 10 character string.

I make my initial auth call:

https://signin.infusionsoft.com/app/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URL&response_type=code

After approving the app I get redirect to my url where I perform a POST request for an access token:

 method: 'post',
 url: 'https://api.infusionsoft.com/token',
 data: '{"client_id":"CLIENT_ID","client_secret":"CLIENT_SECRET","code":"CODE_RETURNED","grant_type":"authorization_code","redirect_uri":"REDIRECT_URL"}' 

I use axios to perform request. It is returning a 401 with this message:

{ error: 'invalid_client' }

Any idea what this means?

1

There are 1 answers

1
cyberwombat On

Ok. I needed to stringify the params. Here's my axios call:

return axios.post('https://api.infusionsoft.com/token', querystring.stringify({
  client_id: CLIENT_ID,
  client_secret: CLIENT_SECRET
  code: CODE_RETURNED,
  grant_type: 'authorization_code',
  redirect_uri: REDIRECT_URL
}), {
  'Content-Type': 'application/x-www-form-urlencoded'
})