I'm writing a .net core console application to run a set of background jobs. The jobs target a Rest API so I'm using Refit library.
The library is quite straightforward but for the authentication part it's a little bit unclear how to achieve it in a clean way.
I have a rest resource for authentication: server/auth/token/acquire
In the body I should send a JSON containing the account and password and then the server sends back an authentication response in the form of :
{
Token: "",
Validity : "",
ExpiresAt : ""
}
I need also a way to cache the token for a duration that is equal to Validity value.
How can I use refit to fulfill these requirements ?
Thanks for helping.