I am creating a client that basically needs to send and retrieve files as an InputStream (it should be) from an endpoint that requires authentication.
I am using Apache HttpClient with the Bearer AuthScheme I created, which processes our own token search stream using a specific cahce for tokens, something around the lines:
@Override public String getToken(Credentials credentials, HttpRequest request, HttpContext context) { return tokenProvider.getToken(getParameters(), request.getRequestLine().getMethod(), request.getRequestLine().getUri()); }
If TokenProvider to go out with its own request for tokens for me from a third-party service.
Now I create my queries using InputStreamEntity , which does not repeat and therefore will fail the second time the request disappears, with the stream:
- The first request fails with error 404
AuthSchem starts to get the requested token based on the request- The client
NonRepeatableRequestException request where it fails with a NonRepeatableRequestException
I know that I can use the Repeatable object and do with it, but we are talking about very (very) large files, I canβt just load them into memory.
I also tried using the HttpRequestInterceptor to proactively execute the first request and populate the marker cache based on the problem it is receiving, but this is really an ugly stream, in my opinion, a token based on the call that the current request will be ready is also retrieved.
I also tried using Jets3t RepeatableRequestEntity , which does the trick, but I prefer not to include dependencies where they really are not needed, and I did not check its performance.
So my question is: how does everyone do this? this is not limited to Bearer authentication - how do you handle sending an InputStream over wiring where request-based authentication is required?