简体   繁体   中英

REST error using InfusionSoft API

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?

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'
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM