public abstract class AbstractOAuth2ApiBinding extends Object implements ApiBinding
Modifier | Constructor and Description |
---|---|
protected |
AbstractOAuth2ApiBinding()
Constructs the API template without user authorization.
|
protected |
AbstractOAuth2ApiBinding(String accessToken)
Constructs the API template with OAuth credentials necessary to perform operations on behalf of a user.
|
Modifier and Type | Method and Description |
---|---|
protected void |
configureRestTemplate(org.springframework.web.client.RestTemplate restTemplate)
Subclassing hook to enable customization of the RestTemplate used to consume provider API resources.
|
protected org.springframework.http.converter.ByteArrayHttpMessageConverter |
getByteArrayMessageConverter()
Returns a
ByteArrayHttpMessageConverter to be used by the internal RestTemplate when consuming image or other binary resources. |
protected org.springframework.http.converter.FormHttpMessageConverter |
getFormMessageConverter()
Returns an
FormHttpMessageConverter to be used by the internal RestTemplate . |
protected org.springframework.http.converter.json.MappingJacksonHttpMessageConverter |
getJsonMessageConverter()
Returns a
MappingJacksonHttpMessageConverter to be used by the internal RestTemplate . |
protected List<org.springframework.http.converter.HttpMessageConverter<?>> |
getMessageConverters()
Returns a list of
HttpMessageConverter s to be used by the internal RestTemplate . |
protected OAuth2Version |
getOAuth2Version()
Returns the version of OAuth2 the API implements.
|
org.springframework.web.client.RestTemplate |
getRestTemplate()
Obtains a reference to the REST client backing this API binding and used to perform API calls.
|
boolean |
isAuthorized()
Returns true if this API binding has been authorized on behalf of a specific user.
|
void |
setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory requestFactory)
Set the ClientHttpRequestFactory.
|
protected AbstractOAuth2ApiBinding()
protected AbstractOAuth2ApiBinding(String accessToken)
accessToken
- the access tokenpublic void setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory requestFactory)
requestFactory
- the request factorypublic boolean isAuthorized()
ApiBinding
isAuthorized
in interface ApiBinding
MissingAuthorizationException
public org.springframework.web.client.RestTemplate getRestTemplate()
RestTemplate.setMessageConverters(java.util.List)
,
RestTemplate.setErrorHandler(org.springframework.web.client.ResponseErrorHandler)
protected OAuth2Version getOAuth2Version()
OAuth2Version.BEARER
indicating versions of OAuth2 that apply the bearer token scheme.
Subclasses may override to return another version.OAuth2Version
protected void configureRestTemplate(org.springframework.web.client.RestTemplate restTemplate)
restTemplate
- the RestTemplate to configure.protected List<org.springframework.http.converter.HttpMessageConverter<?>> getMessageConverters()
HttpMessageConverter
s to be used by the internal RestTemplate
.
By default, this includes a StringHttpMessageConverter
, a MappingJacksonHttpMessageConverter
, a ByteArrayHttpMessageConverter
, and a FormHttpMessageConverter
.
The FormHttpMessageConverter
is set to use "UTF-8" character encoding.
Override this method to add additional message converters or to replace the default list of message converters.protected org.springframework.http.converter.FormHttpMessageConverter getFormMessageConverter()
FormHttpMessageConverter
to be used by the internal RestTemplate
.
By default, the message converter is set to use "UTF-8" character encoding.
Override to customize the message converter (for example, to set supported media types or message converters for the parts of a multipart message).
To remove/replace this or any of the other message converters that are registered by default, override the getMessageConverters() method instead.protected org.springframework.http.converter.json.MappingJacksonHttpMessageConverter getJsonMessageConverter()
MappingJacksonHttpMessageConverter
to be used by the internal RestTemplate
.
Override to customize the message converter (for example, to set a custom object mapper or supported media types).
To remove/replace this or any of the other message converters that are registered by default, override the getMessageConverters() method instead.protected org.springframework.http.converter.ByteArrayHttpMessageConverter getByteArrayMessageConverter()
ByteArrayHttpMessageConverter
to be used by the internal RestTemplate
when consuming image or other binary resources.
By default, the message converter supports "image/jpeg", "image/gif", and "image/png" media types.
Override to customize the message converter (for example, to set supported media types).
To remove/replace this or any of the other message converters that are registered by default, override the getMessageConverters() method instead.Copyright © 2016. All rights reserved.