Package twitter4j
Class OAuthAuthorization
java.lang.Object
twitter4j.OAuthAuthorization
- All Implemented Interfaces:
Serializable
,Authorization
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
encodeParameters
(List<twitter4j.HttpParameter> httpParams) boolean
getAuthorizationHeader
(twitter4j.HttpRequest req) static OAuthAuthorization
Equivalent to OAuthAuthorization.newBuilder().build();static OAuthAuthorization
getInstance
(String consumerKey, String consumerSecret) Equivalent to OAuthAuthorization.newBuilder().oAuthConsumer(key, secret).build();Returns an access token associated with this instance.
If no access token is associated with this instance, this will retrieve a new access token.getOAuthAccessToken
(String oauthVerifier) Retrieves an access token.getOAuthAccessToken
(RequestToken requestToken) Retrieves an access token associated with the supplied request token and sets userId.getOAuthAccessToken
(RequestToken requestToken, String oauthVerifier) Retrieves an access token associated with the supplied request token and sets userId.Retrieves a request tokengetOAuthRequestToken
(String callbackURL) Retrieves a request tokenint
hashCode()
void
Invalidates the OAuth tokenboolean
Returns true if authorization credentials are set.static twitter4j.OAuthAuthorization.OAuthAuthorizationBuilder
toString()
-
Method Details
-
newBuilder
public static twitter4j.OAuthAuthorization.OAuthAuthorizationBuilder newBuilder()- Returns:
- builder for
OAuthAuthorization
-
getInstance
Equivalent to OAuthAuthorization.newBuilder().oAuthConsumer(key, secret).build();- Parameters:
consumerKey
- consumer keyconsumerSecret
- consumer secret- Returns:
- OAuthAuthorization
-
getInstance
Equivalent to OAuthAuthorization.newBuilder().build();- Returns:
- OAuthAuthorization
-
getAuthorizationHeader
- Specified by:
getAuthorizationHeader
in interfaceAuthorization
- Parameters:
req
- request- Returns:
- header
-
isEnabled
public boolean isEnabled()Returns true if authorization credentials are set.- Specified by:
isEnabled
in interfaceAuthorization
- Returns:
- true if authorization credentials are set
-
getOAuthRequestToken
Retrieves a request token- Returns:
- generated request token.
- Throws:
TwitterException
- when Twitter service or network is unavailableIllegalStateException
- access token is already available- Since:
- Twitter4J 2.0.0
- See Also:
-
getOAuthRequestToken
Retrieves a request token- Parameters:
callbackURL
- callback URL- Returns:
- generated request token
- Throws:
TwitterException
- when Twitter service or network is unavailableIllegalStateException
- access token is already available- Since:
- Twitter4J 2.0.0
- See Also:
-
getOAuthAccessToken
Returns an access token associated with this instance.
If no access token is associated with this instance, this will retrieve a new access token.- Returns:
- access token
- Throws:
TwitterException
- when Twitter service or network is unavailable, or the user has not authorizedIllegalStateException
- when RequestToken has never been acquired- Since:
- Twitter4J 2.0.0
- See Also:
-
getOAuthAccessToken
Retrieves an access token.- Parameters:
oauthVerifier
- OAuth verifier. AKA pin.- Returns:
- access token
- Throws:
TwitterException
- when Twitter service or network is unavailable, or the user has not authorized- Since:
- Twitter4J 2.0.0
- See Also:
-
getOAuthAccessToken
Retrieves an access token associated with the supplied request token and sets userId.- Parameters:
requestToken
- the request token- Returns:
- access token associated with the supplied request token.
- Throws:
TwitterException
- when Twitter service or network is unavailable, or the user has not authorized- Since:
- Twitter4J 2.0.0
- See Also:
-
getOAuthAccessToken
public AccessToken getOAuthAccessToken(RequestToken requestToken, String oauthVerifier) throws TwitterException Retrieves an access token associated with the supplied request token and sets userId.- Parameters:
requestToken
- the request tokenoauthVerifier
- OAuth verifier. AKA pin.- Returns:
- access token associated with the supplied request token.
- Throws:
TwitterException
- when Twitter service or network is unavailable, or the user has not authorized- Since:
- Twitter 2.1.1
- See Also:
-
invalidateOAuthToken
Invalidates the OAuth tokenOn success, sets oauthToken to null
- Throws:
TwitterException
- when Twitter service or network is unavailable, or the user has not authorized
-
encodeParameters
- Parameters:
httpParams
- parameters to be encoded and concatenated- Returns:
- encoded string
- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-