twitter4j.auth

## Class OAuth2Authorization

- java.lang.Object
- - twitter4j.auth.OAuth2Authorization

All Implemented Interfaces:
  Serializable, Authorization, OAuth2Support

    public class OAuth2Authorization
    extends Object
    implements Authorization, Serializable, OAuth2Support

Author:
  KOMIYA Atsushi - komiya.atsushi at gmail.com
See Also:
  Application-only authentication, Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`OAuth2Authorization(Configuration conf)`

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `equals(Object obj)`
`String` `getAuthorizationHeader(HttpRequest req)`
`OAuth2Token` `getOAuth2Token()` Obtains an OAuth 2 Bearer token.
`int` `hashCode()`
`void` `invalidateOAuth2Token()` Revokes an issued OAuth 2 Bearer Token.
`boolean` `isEnabled()` Returns true if authorization credentials are set.
`void` `setOAuth2Token(OAuth2Token oauth2Token)` Sets the OAuth 2 Bearer token.
`void` `setOAuthConsumer(String consumerKey, String consumerSecret)` Sets the OAuth consumer key and consumer secret.
`String` `toString()`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### OAuth2Authorization

    public OAuth2Authorization(Configuration conf)

### Method Detail

#### setOAuthConsumer

    public void setOAuthConsumer(String consumerKey,
                                 String consumerSecret)

Description copied from interface: `OAuth2Support`
Sets the OAuth consumer key and consumer secret.

Specified by:
  `setOAuthConsumer` in interface `OAuth2Support`
Parameters:
  `consumerKey` - OAuth consumer key
  `consumerSecret` - OAuth consumer secret

#### getOAuth2Token

    public OAuth2Token getOAuth2Token()
                               throws TwitterException

Description copied from interface: `OAuth2Support`
Obtains an OAuth 2 Bearer token.

Specified by:
  `getOAuth2Token` in interface `OAuth2Support`
Returns:
  OAuth 2 Bearer token
Throws:
  `TwitterException` - when Twitter service or network is unavailable, or connecting non-SSL endpoints.
See Also:
  POST oauth2/token | Twitter Developers

#### setOAuth2Token

    public void setOAuth2Token(OAuth2Token oauth2Token)

Description copied from interface: `OAuth2Support`
Sets the OAuth 2 Bearer token.

Specified by:
  `setOAuth2Token` in interface `OAuth2Support`
Parameters:
  `oauth2Token` - OAuth 2 Bearer token

#### invalidateOAuth2Token

    public void invalidateOAuth2Token()
                               throws TwitterException

Description copied from interface: `OAuth2Support`
Revokes an issued OAuth 2 Bearer Token.

Specified by:
  `invalidateOAuth2Token` in interface `OAuth2Support`
Throws:
  `TwitterException` - when Twitter service or network is unavailable, or connecting non-SSL endpoints.

#### getAuthorizationHeader

    public String getAuthorizationHeader(HttpRequest req)

Specified by:
  `getAuthorizationHeader` in interface `Authorization`

#### isEnabled

    public boolean isEnabled()

Description copied from interface: `Authorization`
Returns true if authorization credentials are set.

Specified by:
  `isEnabled` in interface `Authorization`
Returns:
  true if authorization credentials are set

#### equals

    public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`