I am trying to implement an auth mechanism using access tokens that will expire, and with the ability to retry the Flight API call automatically with the basic credentials(username/pass) when the Flight Server comes back with the access token expired response.
For this, I need to keep track of the previous Flight API call that failed authentication with the access token expired response, along with all the headers that the call included. Once the flight client/client middleware realizes that the access token has expired, it retries the same API call, with all the headers intact, except the authorization token header, which is replaced with the authorization basic credential header(username/pass) and the request is sent to the server again for authentication and processing. Options that I have discovered so far: 1. Modifying the flight client itself to cache the outgoing request and retry the same with a modified authorization header with basic credentials when it receives the access token expired response back from the flight server. 2. Instead of modifying the flight client, a client middleware is passed in via FlightClient.Builder.intercept() method. The client middleware is used to intercept the access token expired response from the server and retry the API call with the modified authorization header, however, I am not certain that the client middleware has the context of the original API call that failed when it intercepts the access token expired response back from the flight server. 3. Have a wrapper impl around the flight client that caches the outgoing request before sending it to the flight client, and once the wrapper receives the token expired response from the server via the flight client, it retries the cached request with the modified authorization header containing the basic Credentials instead of the access token. While this option does not involve the modification of the Arrow Flight code, I still wanted to put this out there as one of the options being considered. Apart from the options above is there any better way to solve this problem? Regards, Keerat