public final class AuthRequestInterceptor extends Object
Interceptor implementation that may be used for interception of requests that require
an authorization token to be sent to the server along with the request data.
An instance of AuthRequestInterceptor requires instance of AuthTokenProvider. Such provider
is than used to peek the authorization token via AuthTokenProvider.peekToken() whenever
intercept(Chain) is invoked. If the peeked token is valid the interceptor will add a new
header into request with name: Authorization and value: Bearer TOKEN_VALUE. If token
provider does not provide valid token, request remains unchanged.
| Constructor and Description |
|---|
AuthRequestInterceptor(AuthTokenProvider tokenProvider)
Creates a new instance of AuthRequestInterceptor with the given authorization tokenProvider.
|
public AuthRequestInterceptor(AuthTokenProvider tokenProvider)
tokenProvider - The desired provider that will be used by the new interceptor to peek
the authorization token when intercepting requests.intercept(Chain)public Response intercept(Chain chain)
throws IOException
IOException