Keap uses OAuth2 to secure calls to our APIs, requiring usage of two flows: the Authorization Code grant (requesting permission from a User for access to their data) and the Refresh Token grant (securing tokens by requiring rotation).
To make calls against the Keap APIs you will need to first obtain an Access Token by requesting authorization then trading in the resulting code. You will receive a Refresh Token at that same time, allowing you to create a new Access Token/Refresh Token pair as they expire.
Authorization Request
The first step in the OAuth flow is to redirect the user to Keap in order to authorize your application for access. The URL you generate here is where you first send your user in order for them to log in and continue the OAuth flow.
Once the user has logged into their Keap account and authorized your application, they will be redirected back to your application at your specified redirect_uri with a code URL parameter that is used to request an access token.
Redirect users to https://accounts.infusionsoft.com/app/oauth/authorize
along with the required parameters in order to start the OAuth exchange.
response_type=code
Defaults to code
.scope=full
Defaults to full
.Access Token Request
The access_token
is the token you will use to authenticate requests to the Keap API, and it expires after the time in the expires_in
field (in seconds). In order to get a new valid access token after one has expired, you must use the refresh_token
to request a new access token.
Using the code URL parameter returned from the authorization callback, your application can request an access token and refresh token from Keap.
Requesting an access token requires you to POST
to https://api.infusionsoft.com/token
Note: The content type should be set to application/x-www-form-urlencoded
.
grant_type=authorization_code
Defaults to authorization_code
.Refresh Request
Provides a new access_token
that you will use to authenticate subsequent requests to the Keap API. Like the originally granted token, this expires after the amount of time in the expires_in
field (in seconds). You must use the newly provided refresh_token
to request a subsequent new access token. Make sure to also store the new refresh token every time you request and store a new access token.
After your access token expires, you’ll use the refresh token that was provided when your access token was initially granted to request a new access token.
Note: Once a Refresh Token is used to receive a new Access Token, you will be returned a new Refresh Token as well, which will need to be persisted in order to request the next access token.
Refreshing an access token requires you to POST
to https://api.infusionsoft.com/token
Note: The content type should be set to application/x-www-form-urlencoded
.
refresh_token
Defaults to refresh_token
.access_token
was granted.client_id
, a colon, and your client_secret
passed via the Authorization
header. Example pseudo code: Basic + base64_encode(CLIENT_ID + ':' + CLIENT_SECRET)
Making API Requests
The base URL for our APIs are https://api.infusionsoft.com/crm/rest
and https://api.infusionsoft.com/crm/xmlrpc
Authorization
header. Example: Bearer 123abc