Implementing Dynamic Authorization in Client Requests from a Layer
Hi folks. I'm in a situation where I need to use a
I have two ideas on how to implement this:
- Every time the client is requested, execute a
- Create a combinator and the token as a dependency with a
How would you implement such service?
Client from a Layer. This client should handle the authorization for every request; the authorization is returned by an HTTP call and has a dynamic ttl returned in the response and needs to be used as a Bearer token in future requests.I have two ideas on how to implement this:
- Every time the client is requested, execute a
Request and set the Cache ttl based on the response. Using @effect/platform set the header. Using @effect/platform/HttpClient set the header in the request and reuse the http client - Create a combinator and the token as a dependency with a
SynchronizedRef and when the response is a 400, retry, get a new token and update the ref to reuse the token in other request.How would you implement such service?
