public class OAuthRestConnection<O extends org.mule.runtime.extension.api.connectivity.oauth.OAuthState> extends DefaultRestConnection
DefaultRestConnection for resources protected with OAuth, regardless of the grant type.| Constructor and Description |
|---|
OAuthRestConnection(org.mule.runtime.http.api.client.HttpClient httpClient,
org.mule.runtime.http.api.client.HttpRequestOptions httpRequestOptions,
String baseUri,
org.mule.runtime.api.el.ExpressionLanguage expressionLanguage,
O oauthState,
String resourceOwnerId) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
authenticate(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder httpRequestBuilder)
Allows to different type of connections to intercept the request before sending the HTTP call.
|
protected void |
authenticate(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder httpRequestBuilder,
O oauthState)
Allows to implement a custom signature for OAuth.
|
protected void |
throwAccessTokenExpiredExceptionIfNeedsRefreshToken(org.mule.runtime.extension.api.error.ErrorTypeDefinition errorTypeDefinition,
String resourceOwnerId)
Template method to allow custom code for triggering a refresh token in case of a different error or custom error types.
|
protected org.mule.runtime.extension.api.exception.ModuleException |
toConnectivityErrorFunction(Throwable throwable)
Template method that allows usage of custom
ErrorTypeDefinition's for general errors like TimeoutException or
IOException which are thrown by the HttpClient API. |
createModuleException, httpResponseToErrorTypeDefinition, materializeHttpResponseEntitybeforeRequest, getBaseUri, getCommonsExpressionLanguage, getExpressionLanguage, getHttpClient, getHttpRequestOptions, getMediaType, send, sendAsync, throwModuleExceptionIfErrorResponse, toResult, validateprotected final void authenticate(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder httpRequestBuilder)
BaseRestConnectionauthenticate in class BaseRestConnection<org.mule.runtime.extension.api.exception.ModuleException,org.mule.runtime.extension.api.error.ErrorTypeDefinition<RestError>>httpRequestBuilder - HttpRequestBuilder populated with the values from the original HttpRequest.protected void authenticate(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder httpRequestBuilder,
O oauthState)
httpRequestBuilder - HttpRequestBuilder to sign the request.oauthState - OAuthState to get access to the access token.protected org.mule.runtime.extension.api.exception.ModuleException toConnectivityErrorFunction(Throwable throwable)
BaseRestConnectionErrorTypeDefinition's for general errors like TimeoutException or
IOException which are thrown by the HttpClient API. The implementation should consider that a
E may be passed to this function in which case it should be propagated as it is. By overriding this method in a
custom connection implementation it will allow customizing these ErrorTypeDefinition's.toConnectivityErrorFunction in class DefaultRestConnectionFunction to handle a Throwable and return a E with its corresponding
ErrorTypeDefinition.protected void throwAccessTokenExpiredExceptionIfNeedsRefreshToken(org.mule.runtime.extension.api.error.ErrorTypeDefinition errorTypeDefinition,
String resourceOwnerId)
RestError.UNAUTHORIZED error code throw the AccessTokenExpiredException so
Mule Runtime/SDK will refresh the access token. DefaultRestConnection.materializeHttpResponseEntity(HttpEntity) in order to allow reading the response entity content
more than once and DefaultRestConnection.httpResponseToErrorTypeDefinition(HttpResponse, MediaType) to associate the
response with a RestError.UNAUTHORIZED or the one that represents this in the custom error type definition for the
connector.errorTypeDefinition - associated to the HttpResponse for the request executed.resourceOwnerId - the oauth resource owner id to be provided by the AccessTokenExpiredException or null.Copyright © 2023. All rights reserved.