Hi, I’m using @elastic/search-ui-elasticsearch-connector/api-proxy to create a connector for my backend (and the backend implements the ElasticsearchAPIConnector).
My backend endpoints requires an Bearer token to be passed on the authorization header, so I’m passing that in the fetchOptions when creating the connector.
The problem
Eventually the access token expires, but I have a refresh token so that I can get a new access token. However, I need to create a new instance of the connector to pass a new token.
Suggested solution
I believe this problem could be solved by having `fetchOptions` accepting a function which could dynamically return headers (including a fresh access token).
Currently I’m looking into the best way to workaround this in my application, and it’s probably going to be a class that extends APIProxyConnector and overrides the methods to “inject” fresh headers, if that makes sense. But it would be nice I could avoid that (and I think passing a function to `fetchOptions` could work).
Has anyone else faced this issue as well? How did you solve it? Have I missed anything?
Thanks in advance!