twitter4j.auth
Interface OAuthSupport

All Known Subinterfaces:
AsyncTwitter, Twitter, TwitterStream
All Known Implementing Classes:
AsyncTwitterImpl, OAuthAuthorization, TwitterBaseImpl, TwitterImpl, TwitterStreamImpl

public interface OAuthSupport

Since:
Twitter4J 2.1.0
Author:
Yusuke Yamamoto - yusuke at mac.com

Method Summary
 AccessToken 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.
 AccessToken getOAuthAccessToken(RequestToken requestToken)
          Retrieves an access token associated with the supplied request token and sets userId.
 AccessToken getOAuthAccessToken(RequestToken requestToken, java.lang.String oauthVerifier)
          Retrieves an access token associated with the supplied request token and sets userId.
 AccessToken getOAuthAccessToken(java.lang.String oauthVerifier)
          Retrieves an access token.
 AccessToken getOAuthAccessToken(java.lang.String screenName, java.lang.String password)
          Retrieves an access token associated with the supplied screen name and password using xAuth.
In order to get access acquire AccessToken using xAuth, you must apply by sending an email to api@twitter.com — all other applications will receive an HTTP 401 error.
 RequestToken getOAuthRequestToken()
          Retrieves a request token
 RequestToken getOAuthRequestToken(java.lang.String callbackURL)
          Retrieves a request token
 void setOAuthAccessToken(AccessToken accessToken)
          Sets the access token
 void setOAuthConsumer(java.lang.String consumerKey, java.lang.String consumerSecret)
          sets the OAuth consumer key and consumer secret
 

Method Detail

setOAuthConsumer

void setOAuthConsumer(java.lang.String consumerKey,
                      java.lang.String consumerSecret)
sets the OAuth consumer key and consumer secret

Parameters:
consumerKey - OAuth consumer key
consumerSecret - OAuth consumer secret
Throws:
java.lang.IllegalStateException - when OAuth consumer has already been set, or the instance is using basic authorization
Since:
Twitter 2.0.0

getOAuthRequestToken

RequestToken getOAuthRequestToken()
                                  throws TwitterException
Retrieves a request token

Returns:
generated request token.
Throws:
TwitterException - when Twitter service or network is unavailable
java.lang.IllegalStateException - access token is already available
Since:
Twitter4J 2.0.0
See Also:
OAuth FAQ | dev.twitter.com, OAuth Core 1.0a - 6.1. Obtaining an Unauthorized Request Token

getOAuthRequestToken

RequestToken getOAuthRequestToken(java.lang.String callbackURL)
                                  throws TwitterException
Retrieves a request token

Parameters:
callbackURL - callback URL
Returns:
generated request token
Throws:
TwitterException - when Twitter service or network is unavailable
java.lang.IllegalStateException - access token is already available
Since:
Twitter4J 2.0.0
See Also:
OAuth FAQ | dev.twitter.com, OAuth Core 1.0a - 6.1. Obtaining an Unauthorized Request Token

getOAuthAccessToken

AccessToken getOAuthAccessToken()
                                throws TwitterException
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 authorized
java.lang.IllegalStateException - when RequestToken has never been acquired
Since:
Twitter4J 2.0.0
See Also:
OAuth FAQ | dev.twitter.com - How long does an access token last?, OAuth Core 1.0a - 6.2. Obtaining User Authorization

getOAuthAccessToken

AccessToken getOAuthAccessToken(java.lang.String oauthVerifier)
                                throws TwitterException
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:
OAuth FAQ | dev.twitter.com - How long does an access token last?, OAuth Core 1.0a - 6.2. Obtaining User Authorization

getOAuthAccessToken

AccessToken getOAuthAccessToken(RequestToken requestToken)
                                throws TwitterException
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:
OAuth FAQ | dev.twitter.com - How long does an access token last?, OAuth Core 1.0a - 6.2. Obtaining User Authorization

getOAuthAccessToken

AccessToken getOAuthAccessToken(RequestToken requestToken,
                                java.lang.String oauthVerifier)
                                throws TwitterException
Retrieves an access token associated with the supplied request token and sets userId.

Parameters:
requestToken - the request token
oauthVerifier - 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:
OAuth Core 1.0a - 6.2. Obtaining User Authorization

getOAuthAccessToken

AccessToken getOAuthAccessToken(java.lang.String screenName,
                                java.lang.String password)
                                throws TwitterException
Retrieves an access token associated with the supplied screen name and password using xAuth.
In order to get access acquire AccessToken using xAuth, you must apply by sending an email to api@twitter.com — all other applications will receive an HTTP 401 error. Web-based applications will not be granted access, except on a temporary basis for when they are converting from basic-authentication support to full OAuth support.
Storage of Twitter usernames and passwords is forbidden. By using xAuth, you are required to store only access tokens and access token secrets. If the access token expires or is expunged by a user, you must ask for their login and password again before exchanging the credentials for an access token.

Parameters:
screenName - the screen name
password - the password
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:
OAuth FAQ | dev.twitter.com - How long does an access token last?, Twitter REST API Method: oauth access_token for xAuth

setOAuthAccessToken

void setOAuthAccessToken(AccessToken accessToken)
Sets the access token

Parameters:
accessToken - accessToken
Since:
Twitter4J 2.0.0