← Back to Upcase

Storing a global variable that changes often

(Austin Wang) #1

I use an external API for a part of an application I’m building. It requires an application wide authentication token to be requested every 2 hours. What is the best way to store this token?

Usually, I store application wide client_ids and client_secrets and such in ypplication.yml, but those typically don’t change
I usually store User level auth_tokens and such on the User model as a column , but in this case it is application wide.

What’s the place mechanism or way to store this global (in that all users will use the same one) string that changes frequently?

(Chad Pytel) #2

I’ve never had to do this before, but I could see a couple options. However, I think the best place is probably in a model, in the database. I’d be happy to discuss if someone has a reason not to do that or a better suggestion.