Feature Request: allow async transformRequest
Motivation
we want to update our refresh token only on map request. But for this asynchron function is needed on the transformRequest callback. Also we need to wait until we received a valid refresh token.
Hi @enersis-pst,
Could you please tell us more about your use case? For example, why do you need to update the token on the map request? Can you call the async function that receives a valid token before the map initialization?
@stepankuzmin yes thanks.
on our angular project all http request use an interceptor for requesting the refresh token. This have a livetime and needs after x minutes to be updated. Only if a new refresh token (for a request) is required, the refresh token will be requested. Like i understand this is the default behaviour. Yes its possible to always request the refresh token before it expired. But the more cleanest way - like i understand - is to only do so if it is requested.
We would also love this, @stepankuzmin!
There are some WMS sources we want to add to our service. However, they require authentication. According to the TOS, these credentials must be kept secret, so we cannot use them directly in our frontend. Therefore, we will proxy them via our backend, but our backend uses JWT for authentication.
This has the same problem as @enersis-pst named, as the JWT is only valid for 60 minutes. If there are 5 minutes or less remaining, the JWT has to be refreshed before making a request. To facilitate this, the getToken() is an async function which encapsulates all this logic (check validity, refresh if needed). It is therefore not feasible to generate a token and reuse it for the lifetime of the application.
I can make an attempt at implementing this feature request if you think that it is a reasonable one.