1

I'm trying to create a webhook from customer.io that will connect to Salesforce via the REST api. As part of that, I need to grab the access_token. This is fine for a while, but the token will eventually expire.

I read this article and they mention running some cron job to update the access_token, but I don't see anywhere the details on how to do that. Has anyone created webhooks from customer.io to Salesforce? How were you able to refresh the access_token at a regular interval?

  • How are you creating a webhook? Their API docs do not show a webhook with outbound authentication. – identigral Jul 1 '19 at 15:41
  • @identigral Please view the article I linked to in the original question – willard Jul 1 '19 at 16:23
1

Issue: customer.io allows you to add a webhook that can call to a Salesforce REST API with an oAuth access token configured in their web UI. Access tokens expire. They don't provide an API for updating the webhook definition (to update the access token) nor do they implement a refresh token flow which would automagically update the access token. As a workaround to prevent the access token from expiring, their doc recommends setting up a "cron job to update the access token more frequently".

What they mean by "more frequently" is that if you periodically call the Salesforce REST API with your access token before the token expires, Salesforce will update the expiration date/time assigned to the token. You can use any Salesforce REST API as your target for this workaround. The same API used in your webhook could work with a dummy payload. Alternatively, you can use a metadata API such as Describe that doesn't create records in Salesforce so there are no side effects or clean up (of dummy records..) required.

If the access token expires every N hours or minutes, I'd make this call exactly once every N/2 hours or minutes. The N/2 value has to do with the way Salesforce updates the expiry time for active sessions (see Note in the Timeout Value section of this doc).

Last but not least, the implementation of this "cron job" can reside in Salesforce (calling out to itself), outside of Salesforce and outside of customer.io (e.g. a traditional cron job running on some UN*X host) or possibly inside customer.io if you can engineer a scheduled call.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.