Lifetime of component

I am in the planning phase of making a component that is going to interface an external API (that I don’t have any documentation for except reverse engineered logs). The API requires identification and the identification query gives you a token that you need to send for each request. This token does expire after a while though.

Should I create my api-wrapper such that every call identifies before doing the api call, or is there some kind of safe storage that I can use to keep the token stored between calls to the api?

If your component creates an object from a component specific class, then you could just save it in an instance variable. Or, you could save it in[DOMAIN], where DOMAIN is the domain name of your component.

How long is “a while”? If there’s a chance that it will expire during normal use, then you’ll need to deal with that, whether you monitor its age or deal with failures when it has expired. If, however, if the “burden” of “identifying” isn’t too bad, then it might be simpler just to do that each time. But that’s a judgement call.