Storing access/refresh tokens for application level API
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
- 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?
- 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.