Is there a pattern for how should I store and reuse a restAPI authorisation token across multiple classes?
I'm consuming a RestAPI, my login code takes a user, password and server and then returns an auth token. That login code sits in a common base class for all my RestAPI calls which works fine. But each new object doesn't know the token so has to reauthorise. I need them to share the same token once it's been generated. I can't use a singleton as I may have to login with multiple different users in the same session.
I'm sure there's a pattern for that but I can't find it, can you help?
Aucun commentaire:
Enregistrer un commentaire