twitter4j.auth

## Interface OAuthSupport

All Known Subinterfaces:
  Twitter

All Known Implementing Classes:
  OAuthAuthorization

    public interface OAuthSupport

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

### Method Summary

All Methods Instance Methods Abstract Methods
`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, String oauthVerifier)` Retrieves an access token associated with the supplied request token and sets userId.
`AccessToken` `getOAuthAccessToken(String oauthVerifier)` Retrieves an access token.
`AccessToken` `getOAuthAccessToken(String screenName, 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(String callbackURL)` Retrieves a request token
`RequestToken` `getOAuthRequestToken(String callbackURL, String xAuthAccessType)` Retrieves a request token
`RequestToken` `getOAuthRequestToken(String callbackURL, String xAuthAccessType, String xAuthMode)` Retrieves a request token
`void` `setOAuthAccessToken(AccessToken accessToken)` Sets the access token
`void` `setOAuthConsumer(String consumerKey, String consumerSecret)` sets the OAuth consumer key and consumer secret

### Method Detail

#### setOAuthConsumer

    void setOAuthConsumer(String consumerKey,
                          String consumerSecret)

sets the OAuth consumer key and consumer secret

Parameters:
  `consumerKey` - OAuth consumer key
  `consumerSecret` - OAuth consumer secret
Throws:
  `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
  `IllegalStateException` - access token is already available
Since:
  Twitter4J 2.0.0
See Also:
  OAuth FAQ | Twitter Developers, OAuth Core 1.0a - 6.1. Obtaining an Unauthorized Request Token, POST oauth/request_token | Twitter Developers

#### getOAuthRequestToken

    RequestToken getOAuthRequestToken(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
  `IllegalStateException` - access token is already available
Since:
  Twitter4J 2.0.0
See Also:
  OAuth FAQ | Twitter Developers, OAuth Core 1.0a - 6.1. Obtaining an Unauthorized Request Token, POST oauth/request_token | Twitter Developers

#### getOAuthRequestToken

    RequestToken getOAuthRequestToken(String callbackURL,
                                      String xAuthAccessType)
                               throws TwitterException

Retrieves a request token

Parameters:
  `callbackURL` - callback URL
  `xAuthAccessType` - Overrides the access level an application requests to a users account. Supported values are read or write. This parameter is intended to allow a developer to register a read/write application but also request read only access when appropriate.
Returns:
  generated request token
Throws:
  `TwitterException` - when Twitter service or network is unavailable
  `IllegalStateException` - access token is already available
Since:
  Twitter4J 2.2.3
See Also:
  OAuth FAQ | Twitter Developers, OAuth Core 1.0a - 6.1. Obtaining an Unauthorized Request Token, POST oauth/request_token | Twitter Developers

#### getOAuthRequestToken

    RequestToken getOAuthRequestToken(String callbackURL,
                                      String xAuthAccessType,
                                      String xAuthMode)
                               throws TwitterException

Retrieves a request token

Parameters:
  `callbackURL` - callback URL
  `xAuthAccessType` - Overrides the access level an application requests to a users account. Supported values are read or write. This parameter is intended to allow a developer to register a read/write application but also request read only access when appropriate.
  `xAuthMode` - Set to reverse_auth to obtain a special request token to be used in the reverse auth process.
Returns:
  generated request token
Throws:
  `TwitterException` - when Twitter service or network is unavailable
  `IllegalStateException` - access token is already available
Since:
  Twitter4J 2.2.3
See Also:
  OAuth FAQ | Twitter Developers, OAuth Core 1.0a - 6.1. Obtaining an Unauthorized Request Token, POST oauth/request_token | Twitter Developers

#### 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
  `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, POST oauth/access_token | Twitter Developers

#### getOAuthAccessToken

    AccessToken getOAuthAccessToken(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, POST oauth/access_token | Twitter Developers

#### 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, POST oauth/access_token | Twitter Developers

#### getOAuthAccessToken

    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 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, POST oauth/access_token | Twitter Developers

#### getOAuthAccessToken

    AccessToken getOAuthAccessToken(String screenName,
                                    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?, xAuth | Twitter Developers, POST oauth/access_token | Twitter Developers

#### setOAuthAccessToken

    void setOAuthAccessToken(AccessToken accessToken)

Sets the access token

Parameters:
  `accessToken` - accessToken
Since:
  Twitter4J 2.0.0