public class OAuth1Template extends Object implements OAuth1Operations
Constructor and Description |
---|
OAuth1Template(String consumerKey,
String consumerSecret,
String requestTokenUrl,
String authorizeUrl,
String accessTokenUrl) |
OAuth1Template(String consumerKey,
String consumerSecret,
String requestTokenUrl,
String authorizeUrl,
String accessTokenUrl,
OAuth1Version version) |
OAuth1Template(String consumerKey,
String consumerSecret,
String requestTokenUrl,
String authorizeUrl,
String authenticateUrl,
String accessTokenUrl) |
OAuth1Template(String consumerKey,
String consumerSecret,
String requestTokenUrl,
String authorizeUrl,
String authenticateUrl,
String accessTokenUrl,
OAuth1Version version) |
Modifier and Type | Method and Description |
---|---|
protected void |
addCustomAuthorizationParameters(MultiValueMap<String,String> parameters)
Subclassing hook to add custom authorization parameters to the authorization URL.
|
String |
buildAuthenticateUrl(String requestToken,
OAuth1Parameters parameters)
Construct the URL to redirect the user to for authentication.
|
String |
buildAuthorizeUrl(String requestToken,
OAuth1Parameters parameters)
Construct the URL to redirect the user to for authorization.
|
protected OAuthToken |
createOAuthToken(String tokenValue,
String tokenSecret,
MultiValueMap<String,String> response)
Creates an
OAuthToken given the response from the request token or access token exchange with the provider. |
OAuthToken |
exchangeForAccessToken(AuthorizedRequestToken requestToken,
MultiValueMap<String,String> additionalParameters)
Exchange the authorized request token for an access token.
|
OAuthToken |
fetchRequestToken(String callbackUrl,
MultiValueMap<String,String> additionalParameters)
Begin a new authorization flow by fetching a new request token from this service provider.
|
protected String |
getConsumerKey()
Exposes the consumer key to be read by subclasses.
|
OAuth1Version |
getVersion()
The version of OAuth1 implemented by this operations instance.
|
void |
setRequestFactory(ClientHttpRequestFactory requestFactory)
Set the request factory on the underlying RestTemplate.
|
public OAuth1Template(String consumerKey, String consumerSecret, String requestTokenUrl, String authorizeUrl, String accessTokenUrl)
public OAuth1Template(String consumerKey, String consumerSecret, String requestTokenUrl, String authorizeUrl, String accessTokenUrl, OAuth1Version version)
public OAuth1Template(String consumerKey, String consumerSecret, String requestTokenUrl, String authorizeUrl, String authenticateUrl, String accessTokenUrl)
public void setRequestFactory(ClientHttpRequestFactory requestFactory)
requestFactory
- the request factory on the underlying RestTemplate.public OAuth1Version getVersion()
OAuth1Operations
getVersion
in interface OAuth1Operations
OAuth1Version.CORE_10
,
OAuth1Version.CORE_10_REVISION_A
public OAuthToken fetchRequestToken(String callbackUrl, MultiValueMap<String,String> additionalParameters)
OAuth1Operations
access token
.fetchRequestToken
in interface OAuth1Operations
callbackUrl
- the URL the provider should redirect to after the member authorizes the connection. Ignored for OAuth 1.0 providers.additionalParameters
- any additional query parameters to be sent when fetching the request token. Should not be encoded.public String buildAuthorizeUrl(String requestToken, OAuth1Parameters parameters)
OAuth1Operations
buildAuthorizeUrl
in interface OAuth1Operations
requestToken
- the request token value, to be encoded in the authorize URL.parameters
- parameters to pass to the provider in the authorize URL. Should never be null; if there are no parameters to pass, set this argument value to OAuth1Parameters.NONE
.public String buildAuthenticateUrl(String requestToken, OAuth1Parameters parameters)
OAuth1Operations
buildAuthenticateUrl
in interface OAuth1Operations
requestToken
- the request token value, to be encoded in the authorize URL.parameters
- parameters to pass to the provider in the authenticate URL. Should never be null; if there are no parameters to pass, set this argument value to OAuth1Parameters.NONE
.public OAuthToken exchangeForAccessToken(AuthorizedRequestToken requestToken, MultiValueMap<String,String> additionalParameters)
OAuth1Operations
exchangeForAccessToken
in interface OAuth1Operations
requestToken
- an authorized request token and verifier. The verifier will be ignored for OAuth 1.0 providers.additionalParameters
- any additional query parameters to be sent when fetching the access token. Should not be encoded.protected String getConsumerKey()
addCustomAuthorizationParameters(MultiValueMap)
and the consumer key is required in the authorization request.protected OAuthToken createOAuthToken(String tokenValue, String tokenSecret, MultiValueMap<String,String> response)
OAuthToken
given the response from the request token or access token exchange with the provider.
May be overridden to create a custom OAuthToken
.tokenValue
- the token value received from the provider.tokenSecret
- the token secret received from the provider.response
- all parameters from the response received in the request/access token exchange.OAuthToken
protected void addCustomAuthorizationParameters(MultiValueMap<String,String> parameters)
parameters
- custom parameters for authorization