Ask A Question


You’re not receiving notifications from this thread.

Storing access/refresh tokens for application level API

RJ McCollam asked in Rails

I am working on an application that integrates with Keap (a CRM). The integration with Keap is at the application level in that it only connects to one Keap account, and isn't a connection per user in the application.

The Keap API authenticates with OAuth and I have 2 questions I am looking for some guidance on

  1. Storing my access/refresh tokens — I'm not entirely sure the best place to store these values. I will be referencing their values in an initializer and will be updating them on the regular. Is there a better mechanism to store these values outside of creating a new model with these fields and always just updating the first record in that model?
  2. Recurring/CRON Jobs - I will need to run a job every 23hrs to refresh my access token. Assuming I go the model route on the question above my plan would be to setup an active job to be setup every time a record is updated. Setting the wait to be 23hrs from when the update happens. Is there a more efficient way to do this, or is ActiveJob the rails way to accomplish this?

As I make progress and think through this I guess I can't rely on referencing this value in an initializer unless I want to restart the app every day. Which I don't.

The better solution seems to wrap my API calls in my own wrapper rather than relying on the gem I was going to use.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 78,890+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2023 GoRails, LLC. All rights reserved.