public class OAuth1WithCallback extends OAuth1Generic
begin()
to obtain a temporary token and a redirect URL if OAuth1Generic.authoriseUrl
was provided (not null).
authorised(String, String)
with the temporary token obtained in (1), and the verifier (provided as a parameter to the callback, as parsed on the front-end).
OAuthParameters
object that can be used to make requests on the user's behalf. Using the OAuthParameters
make a request to a given URL with a given HTTP request method and body via OAuth1Generic.makeOAuthBackedRequest(String, OAuthParameters, RequestMethod, HttpContent)
.accessTokenUrl, authoriseUrl, callbackUrl, consumerKey, consumerSecret, requestTokenUrl, tokenMapStrategy
Constructor and Description |
---|
OAuth1WithCallback(String consumerKey,
String consumerSecret,
String requestTokenUrl,
String callbackUrl,
String authoriseUrl,
String accessTokenUrl,
TokenMapStrategy tokenMapStrategy) |
Modifier and Type | Method and Description |
---|---|
AuthorisedResult |
authorised(String temporaryToken,
String verifier)
Fetches the token secret corresponding to the temporary token,
then uses the obtained token secret along with the original temporary token and verifier to obtain an access token from the server.
|
BeginResult |
begin()
Requests a temporary token and corresponding token secret from the server,
then maps the temporary token to the token secret
and returns the obtained temporary token along with the authenticate URL (redirect URL) if
OAuth1Generic.authoriseUrl is non-null. |
makeOAuthBackedRequest
public OAuth1WithCallback(@Nonnull String consumerKey, @Nonnull String consumerSecret, @Nonnull String requestTokenUrl, @Nonnull String callbackUrl, @Nullable String authoriseUrl, @Nonnull String accessTokenUrl, @Nonnull TokenMapStrategy tokenMapStrategy)
consumerKey
- Required identifier portion of the client credentials (equivalent to a username). More information: client_id entry of the OAuthParameters table at https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtmlconsumerSecret
- Client-shared secret. More information: client_id entry of the OAuthParameters table at https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtmlrequestTokenUrl
- Encoded authorization server URL. More information: request_uri entry of the OAuthParameters table at https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtmlcallbackUrl
- Optional absolute URI back to which the server will redirect the resource owner when the Resource Owner Authorization step is completed or null for none. More information: redirect_uri entry of the OAuthParameters table at https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtmlauthoriseUrl
- Encoded user authorization URL, or null if only wish to receive the temporary token and build it themselves.accessTokenUrl
- Encoded authorization server URL.tokenMapStrategy
- Strategy to map temporary tokens to token secrets, and fetch the token secret for a temporary token.@Nonnull public BeginResult begin() throws GetTemporaryTokenException, TokenMapException
OAuth1Generic.authoriseUrl
is non-null.begin
in class OAuth1Generic
OAuth1Generic.authoriseUrl
is non-null, otherwise null.GetTemporaryTokenException
- If the request to the server for the temporary token failed.TokenMapException
- If mapping the obtained temporary token to the obtained token secret failed.@Nonnull public AuthorisedResult authorised(@Nonnull String temporaryToken, @Nonnull String verifier) throws GetAccessTokenException, TokenMapException
authorised
in class OAuth1Generic
temporaryToken
- The temporary token obtained from begin()
verifier
- The verifier.OAuthParameters
object used to make OAuth-backed requests on behalf of the access token via OAuth1Generic.makeOAuthBackedRequest(String, OAuthParameters, RequestMethod, HttpContent)
GetAccessTokenException
- If the request to the server for the access token failed.TokenMapException
- If fetching the token secret corresponding to the given temporary token failed.Copyright © 2020. All rights reserved.