3

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.

Isser Zack
  • 39
  • 3
  • There's no caching here - I guess you'd have to do that yourself - but there's a pretty good example here https://github.com/renatogroffe/DotNetCore2.2_Refit-JWT – Rich Bryant Jan 02 '20 at 11:27

0 Answers0