Package twitter4j

Class OAuth2Authorization

java.lang.Object
twitter4j.OAuth2Authorization
All Implemented Interfaces:
Serializable, Authorization

public class OAuth2Authorization extends Object implements Authorization, Serializable
See Also:
  • Method Details

    • newBuilder

      public static twitter4j.OAuth2Authorization.OAuth2AuthorizationBuilder newBuilder()
      Returns:
      builder for OAuth2Authorization
    • getInstance

      public static OAuth2Authorization getInstance(String consumerKey, String consumerSecret)
      Equivalent to OAuth2Authorization.newBuilder().oAuthConsumer(key, secret).build();
      Parameters:
      consumerKey - consumer key
      consumerSecret - consumer secret
      Returns:
      OAuth2Authorization
    • getInstance

      public static OAuth2Authorization getInstance()
      Equivalent to OAuth2Authorization.newBuilder().build();
      Returns:
      OAuth2Authorization
    • getOAuth2Token

      public OAuth2Token getOAuth2Token() throws TwitterException
      Obtains an OAuth 2 Bearer token.
      Returns:
      OAuth 2 Bearer token
      Throws:
      TwitterException - when Twitter service or network is unavailable, or connecting non-SSL endpoints.
      IllegalStateException - when Bearer token is already available, or OAuth consumer is not available.
      See Also:
    • invalidateOAuth2Token

      public void invalidateOAuth2Token() throws TwitterException
      Revokes an issued OAuth 2 Bearer Token.
      Throws:
      TwitterException - when Twitter service or network is unavailable, or connecting non-SSL endpoints.
      IllegalStateException - when Bearer token is not available.
    • getAuthorizationHeader

      public String getAuthorizationHeader(twitter4j.HttpRequest req)
      Specified by:
      getAuthorizationHeader in interface Authorization
      Parameters:
      req - request
      Returns:
      header
    • 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 o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object