REQUEST
- The request type.RESPONSE
- The response type.public abstract class RefreshAuthTokenWrappingAsyncHandler<REQUEST,RESPONSE> extends Object implements AsyncHandler<REQUEST,RESPONSE>
Callbacks for asynchronous requests intended to work with some authenticated calls, like instance principals. This handler wraps a base AsyncHandler and has additional logic so that if a call fails with a 401, we’ll refresh the auth token and then try again up to a given number of retries (it is recommended that we only do one retry).
This is to account for scenarios where we have a valid/non-expired token but the permissions for the instance have changed since the token was issued and so on the server-side the presented token is considered invalid.
Constructor and Description |
---|
RefreshAuthTokenWrappingAsyncHandler(RefreshableOnNotAuthenticatedProvider<?> authDetailsProvider,
AsyncHandler<REQUEST,RESPONSE> innerHandler)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
onError(REQUEST request,
Throwable error)
Deprecated.
Called if the request could not be completed successfully.
|
void |
onSuccess(REQUEST request,
RESPONSE response)
Deprecated.
Called if the request was successfully completed.
|
abstract void |
retryCall()
Deprecated.
If we need to retry the request (i.e.
|
public RefreshAuthTokenWrappingAsyncHandler(RefreshableOnNotAuthenticatedProvider<?> authDetailsProvider, AsyncHandler<REQUEST,RESPONSE> innerHandler)
public void onSuccess(REQUEST request, RESPONSE response)
AsyncHandler
Called if the request was successfully completed.
onSuccess
in interface AsyncHandler<REQUEST,RESPONSE>
request
- The request that was made.response
- The response that was received.public void onError(REQUEST request, Throwable error)
AsyncHandler
Called if the request could not be completed successfully.
onError
in interface AsyncHandler<REQUEST,RESPONSE>
request
- The request that was made.error
- The error that was received.public abstract void retryCall()
If we need to retry the request (i.e. on a 401), this method contains the information on how to do that. This method will be leveraged by the onError callback of this handler.
Copyright © 2016–2024. All rights reserved.