Preemptive authentication with OkHttpClient without ProxyServer

Viewed 485

As per https://square.github.io/okhttp/3.x/okhttp/ , I think preemptive authentication can happen only if we have proxy server.

We have one resource/origin server which authorises clients with Oauth tokens.

We have implemented authorisation OkHttp Authenticator https://square.github.io/okhttp/3.x/okhttp/okhttp3/Authenticator.html . However, the client always makes a request without authorisation headers and then adds it. Can we use authenticator and still supply authorisation header to our resource server in a single request ? We can predict the challenge. However, not sure if it's possible to avoid a request to server without authorisation headers.

We are able to use the interceptor to add headers preemptively.

Is it possible to use Authenticator and add headers preemptively without a proxy server?

1 Answers
Related