I only want to add a contact but trying to get access is so hard

Hi,

I continue my inquiry from this post: Developer account and API keys .

I will make a resume to help you understand the issue.

I only want to add a contact (name, phone, email, address etc) to a Keap account. I try to do that using REST API Version 2 with PHP & cURL. I have created an account in developer.keap.com in order to get the Client id and the secret.

The answer from OmarAlmonte suggests to to obtain an access token. And as the instructions say in Getting Started with OAuth2 - Keap Developer Portal I have to “…redirect the user to Keap in order to authorize your application for access…” and use a call like the following:

https://accounts.infusionsoft.com/app/oauth/authorize?client_id=123ABC&redirect_uri=https%3A%2F%2Fwebsite.com%2Fkeap%2Ftest.php&response_type=code&scope=full

in order to take the access_token.

I have two problems here:

  1. It says the redirect url is wrong. There is no reason why not to accept that url.
  2. Despite the above, I do not want to require from any user to give access each time I want to add a contact in the same Keap account. I want to have permanent access and the new contact to be added seamlessly to the Keap account.

I hope all the above is not too much,
Thanks

Hi @Thanos_Manesis,

That redirect_uri does look valid. If it’s being rejected, the most common cause is an incorrect client_id. Even though the example value isn’t what you’re using, I’d recommend double-checking it in the Keap Developer Portal by signing in, going to Apps, selecting your app, and copying the Client ID from the API Keys section.

Regarding OAuth, once you complete the authorization flow, you’ll receive both an access token and a refresh token. You can use the refresh token to obtain new access tokens as they expire, so the user does not need to re-authorize your app each time. That refresh flow is covered here in more detail:
Getting Started with OAuth2 – Keap Developer Portal.

That said, if your use case is simply adding contacts to a single Keap account and you don’t need a full third-party OAuth flow, you may want to consider a Personal Access Token (PAT) or a Service Account Key (SAK) instead. You can generate either by signing in to the Keap app and navigating to Settings → API, then selecting the Personal Access Tokens or Service Account Keys tab.

Once created, you can authenticate your requests by including the token in the Authorization header as a Bearer token, for example:

curl --request POST 'https://api.infusionsoft.com/crm/rest/v2/contacts' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "given_name": "Thanos",
    "family_name": "Manesis",
    "email_addresses": [
      {
        "email": "thanos@example.com",
        "field": "EMAIL1"
      }
    ],
    "phone_numbers": [
      {
        "number": "+15025551234",
        "field": "PHONE1",
        "type": "mobile"
      }
    ]
  }'

1 Like

Hi and thank you for your answer which was very helpful.

Your suggestion to use Personal Access Token was much easier.

Thanks

1 Like