This might be a dumb question. We are calling an API that requires oAuth. The token should be good for an hour. Where would you store the token and expiration date? Right now, we are storing it as a property on the model that does the interaction with the API. We check if it is still valid and get a new one if we need to. But a fwreinit (in ColdBox) is forcing a new token even if it hadn’t expired, which feels weird. Should it be stored in a broader application scope somewhere? Thoughts?
s
seancorfield
01/12/2024, 9:11 PM
How often are you reinit-ing ColdBox??
seancorfield
01/12/2024, 9:12 PM
Seems like that should only happen occasionally (except in dev?) so I wouldn't worry about it requesting a new token since fwreinit is like "startup" anyway...
d
danmurphy
01/12/2024, 9:30 PM
Yes, you’re correct, it’s not happening often. We just came across it as we were working on something with it locally and it just felt weird. Felt like a bug in our logic.
danmurphy
01/12/2024, 9:35 PM
@elpete - you mentioned a persistent cache. We aren’t using one yet, unfotunately. What would one layer up from that be? Something at the application level? (Not sure what that would look like). Alternatively, yes, we could keep it on the model and we might do just that. I’m just trying to learn a bit here too.
e
elpete
01/12/2024, 9:36 PM
You could store it directly in the application or server scope, perhaps.
q
quetwo
01/13/2024, 3:02 AM
I tend to store those things in a DB, if it makes sense. That way if the container gets restarted (or another instance gets spun up), they don't need to request a new one. Something like Reddis would work for that too