twitter4j
Class TwitterOAuthSupportBaseImpl

java.lang.Object
  extended by twitter4j.TwitterBase
      extended by twitter4j.TwitterOAuthSupportBase
          extended by twitter4j.TwitterOAuthSupportBaseImpl
All Implemented Interfaces:
java.io.Serializable, OAuthSupport, twitter4j.internal.http.HttpResponseCode, twitter4j.internal.http.HttpResponseListener
Direct Known Subclasses:
Twitter, TwitterStream

 class TwitterOAuthSupportBaseImpl
extends TwitterOAuthSupportBase

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

Field Summary
protected  int id
           
protected  java.lang.String screenName
           
 
Fields inherited from class twitter4j.TwitterOAuthSupportBase
http, rateLimitStatusListener
 
Fields inherited from class twitter4j.TwitterBase
auth, conf
 
Fields inherited from interface twitter4j.internal.http.HttpResponseCode
BAD_GATEWAY, BAD_REQUEST, ENHANCE_YOUR_CLAIM, FORBIDDEN, INTERNAL_SERVER_ERROR, MULTIPLE_CHOICES, NOT_ACCEPTABLE, NOT_FOUND, NOT_MODIFIED, OK, SERVICE_UNAVAILABLE, UNAUTHORIZED
 
Constructor Summary
TwitterOAuthSupportBaseImpl()
           
TwitterOAuthSupportBaseImpl(Configuration conf)
           
TwitterOAuthSupportBaseImpl(Configuration conf, Authorization auth)
           
TwitterOAuthSupportBaseImpl(Configuration conf, java.lang.String screenName, java.lang.String password)
           
TwitterOAuthSupportBaseImpl(java.lang.String screenName, java.lang.String password)
           
 
Method Summary
private  OAuthSupport getOAuth()
           
 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 token, java.lang.String tokenSecret)
          Deprecated. Use TwitterFactory.getInstance(twitter4j.http.Authorization) instead
 AccessToken getOAuthAccessToken(java.lang.String token, java.lang.String tokenSecret, java.lang.String pin)
          Retrieves an access token associated with the supplied request token.
 RequestToken getOAuthRequestToken()
          Retrieves a request token
 RequestToken getOAuthRequestToken(java.lang.String callbackUrl)
          Retrieves a request token
 boolean isOAuthEnabled()
          tests if the instance is authenticated by Basic
 void setOAuthAccessToken(AccessToken accessToken)
          Deprecated. Use TwitterFactory.getInstance(twitter4j.http.Authorization) instead
 void setOAuthAccessToken(java.lang.String token, java.lang.String tokenSecret)
          Deprecated. Use TwitterFactory.getInstance(twitter4j.http.Authorization) instead
 void setOAuthConsumer(java.lang.String consumerKey, java.lang.String consumerSecret)
          sets the OAuth consumer key and consumer secret
 
Methods inherited from class twitter4j.TwitterOAuthSupportBase
equals, hashCode, httpResponseReceived, setRateLimitStatusListener, shutdown
 
Methods inherited from class twitter4j.TwitterBase
ensureAuthorizationEnabled, ensureBasicEnabled, getAuthorization, isBasicAuthEnabled, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

screenName

protected transient java.lang.String screenName

id

protected transient int id
Constructor Detail

TwitterOAuthSupportBaseImpl

TwitterOAuthSupportBaseImpl(Configuration conf)

TwitterOAuthSupportBaseImpl

TwitterOAuthSupportBaseImpl()

TwitterOAuthSupportBaseImpl

TwitterOAuthSupportBaseImpl(java.lang.String screenName,
                            java.lang.String password)

TwitterOAuthSupportBaseImpl

TwitterOAuthSupportBaseImpl(Configuration conf,
                            java.lang.String screenName,
                            java.lang.String password)

TwitterOAuthSupportBaseImpl

TwitterOAuthSupportBaseImpl(Configuration conf,
                            Authorization auth)
Method Detail

getOAuthRequestToken

public RequestToken getOAuthRequestToken()
                                  throws TwitterException
Retrieves a request token

Specified by:
getOAuthRequestToken in interface OAuthSupport
Specified by:
getOAuthRequestToken in class TwitterOAuthSupportBase
Returns:
generated request token.
Throws:
TwitterException - when Twitter service or network is unavailable
See Also:
OAuth FAQ | dev.twitter.com, OAuth Core 1.0a - 6.1. Obtaining an Unauthorized Request Token

getOAuthRequestToken

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

Specified by:
getOAuthRequestToken in interface OAuthSupport
Specified by:
getOAuthRequestToken in class TwitterOAuthSupportBase
Parameters:
callbackUrl - callback URL
Returns:
generated request token
Throws:
TwitterException - when Twitter service or network is unavailable
See Also:
OAuth FAQ | dev.twitter.com, OAuth Core 1.0a - 6.1. Obtaining an Unauthorized Request Token

getOAuthAccessToken

public 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. Basic authenticated instance of this class will try acquiring an AccessToken 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.

Specified by:
getOAuthAccessToken in interface OAuthSupport
Specified by:
getOAuthAccessToken in class TwitterOAuthSupportBase
Returns:
access token
Throws:
TwitterException - When Twitter service or network is unavailable, when the user has not authorized, or when the client application is not permitted to use xAuth
See Also:
Twitter REST API Method: oauth access_token for xAuth

getOAuthAccessToken

public AccessToken getOAuthAccessToken(java.lang.String oauthVerifier)
                                throws TwitterException
Retrieves an access token.

Specified by:
getOAuthAccessToken in interface OAuthSupport
Specified by:
getOAuthAccessToken in class TwitterOAuthSupportBase
Parameters:
oauthVerifier - OAuth verifier. AKA pin.
Returns:
access token
Throws:
java.lang.IllegalStateException - when AccessToken has already been retrieved or set
TwitterException - when Twitter service or network is unavailable, or the user has not authorized
See Also:
OAuth FAQ | dev.twitter.com - How long does an access token last?, OAuth Core 1.0a - 6.2. Obtaining User Authorization

getOAuthAccessToken

public AccessToken getOAuthAccessToken(RequestToken requestToken)
                                throws TwitterException
Retrieves an access token associated with the supplied request token and sets userId.

Specified by:
getOAuthAccessToken in interface OAuthSupport
Specified by:
getOAuthAccessToken in class TwitterOAuthSupportBase
Parameters:
requestToken - the request token
Returns:
access token associated with the supplied request token.
Throws:
java.lang.IllegalStateException - when AccessToken has already been retrieved or set
TwitterException - when Twitter service or network is unavailable, or the user has not authorized
See Also:
OAuth FAQ | dev.twitter.com - How long does an access token last?, OAuth Core 1.0a - 6.2. Obtaining User Authorization

getOAuthAccessToken

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

Specified by:
getOAuthAccessToken in interface OAuthSupport
Specified by:
getOAuthAccessToken in class TwitterOAuthSupportBase
Parameters:
requestToken - the request token
oauthVerifier - OAuth verifier. AKA pin.
Returns:
access token associated with the supplied request token.
Throws:
java.lang.IllegalStateException - when AccessToken has already been retrieved or set
TwitterException - when Twitter service or network is unavailable, or the user has not authorized
See Also:
OAuth Core 1.0a - 6.2. Obtaining User Authorization

setOAuthAccessToken

public void setOAuthAccessToken(AccessToken accessToken)
Deprecated. Use TwitterFactory.getInstance(twitter4j.http.Authorization) instead

Sets the access token

Specified by:
setOAuthAccessToken in interface OAuthSupport
Specified by:
setOAuthAccessToken in class TwitterOAuthSupportBase
Parameters:
accessToken - accessToken

getOAuthAccessToken

public AccessToken getOAuthAccessToken(java.lang.String token,
                                       java.lang.String tokenSecret)
                                throws TwitterException
Deprecated. Use TwitterFactory.getInstance(twitter4j.http.Authorization) instead

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.

Specified by:
getOAuthAccessToken in interface OAuthSupport
Specified by:
getOAuthAccessToken in class TwitterOAuthSupportBase
Parameters:
token - the screen name
tokenSecret - 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
See Also:
OAuth FAQ | dev.twitter.com - How long does an access token last?, Twitter REST API Method: oauth access_token for xAuth

getOAuthAccessToken

public AccessToken getOAuthAccessToken(java.lang.String token,
                                       java.lang.String tokenSecret,
                                       java.lang.String pin)
                                throws TwitterException
Retrieves an access token associated with the supplied request token.

Specified by:
getOAuthAccessToken in class TwitterOAuthSupportBase
Parameters:
token - request token
tokenSecret - request token secret
pin - 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
See Also:
Twitter API Wiki - How long does an access token last?, OAuth Core 1.0a - 6.2. Obtaining User Authorization

setOAuthAccessToken

public void setOAuthAccessToken(java.lang.String token,
                                java.lang.String tokenSecret)
Deprecated. Use TwitterFactory.getInstance(twitter4j.http.Authorization) instead

Sets the access token

Specified by:
setOAuthAccessToken in class TwitterOAuthSupportBase
Parameters:
token - access token
tokenSecret - access token secret
Throws:
java.lang.IllegalStateException - when AccessToken has already been retrieved or set
Since:
Twitter 2.0.0

isOAuthEnabled

public boolean isOAuthEnabled()
tests if the instance is authenticated by Basic

Overrides:
isOAuthEnabled in class TwitterOAuthSupportBase
Returns:
returns true if the instance is authenticated by Basic

getOAuth

private OAuthSupport getOAuth()

setOAuthConsumer

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

Specified by:
setOAuthConsumer in class TwitterOAuthSupportBase
Parameters:
consumerKey - OAuth consumer key
consumerSecret - OAuth consumer secret