### Home Classes Methods

### In Files

- lib/twitter/rest/oauth.rb

### Methods

- #bearer_token
- #invalidate_token
- #reverse_token
- #token

### Included Modules

- Twitter::REST::Utils

### Class/Module Index

Quicksearch

- Twitter
- Twitter::Arguments
- Twitter::Base
- Twitter::BasicUser
- Twitter::Client
- Twitter::Configuration
- Twitter::Creatable
- Twitter::Cursor
- Twitter::DirectMessage
- Twitter::Entities
- Twitter::Entity
- Twitter::Entity::Hashtag
- Twitter::Entity::Symbol
- Twitter::Entity::URI
- Twitter::Entity::URL
- Twitter::Entity::UserMention
- Twitter::Enumerable
- Twitter::Error
- Twitter::Error::AlreadyFavorited
- Twitter::Error::AlreadyRetweeted
- Twitter::Error::BadGateway
- Twitter::Error::BadRequest
- Twitter::Error::ClientError
- Twitter::Error::Code
- Twitter::Error::ConfigurationError
- Twitter::Error::DuplicateStatus
- Twitter::Error::Forbidden
- Twitter::Error::GatewayTimeout
- Twitter::Error::InternalServerError
- Twitter::Error::NotAcceptable
- Twitter::Error::NotFound
- Twitter::Error::RequestTimeout
- Twitter::Error::ServerError
- Twitter::Error::ServiceUnavailable
- Twitter::Error::TooManyRequests
- Twitter::Error::UnacceptableIO
- Twitter::Error::Unauthorized
- Twitter::Error::UnprocessableEntity
- Twitter::Factory
- Twitter::Geo
- Twitter::Geo::Point
- Twitter::Geo::Polygon
- Twitter::GeoFactory
- Twitter::GeoResults
- Twitter::Identity
- Twitter::Language
- Twitter::List
- Twitter::Media
- Twitter::Media::Photo
- Twitter::MediaFactory
- Twitter::Metadata
- Twitter::OEmbed
- Twitter::Place
- Twitter::Profile
- Twitter::ProfileBanner
- Twitter::REST
- Twitter::REST::API
- Twitter::REST::Client
- Twitter::REST::DirectMessages
- Twitter::REST::Favorites
- Twitter::REST::FriendsAndFollowers
- Twitter::REST::Help
- Twitter::REST::Lists
- Twitter::REST::OAuth
- Twitter::REST::PlacesAndGeo
- Twitter::REST::Request
- Twitter::REST::Request::MultipartWithFile
- Twitter::REST::Response
- Twitter::REST::Response::ParseErrorJson
- Twitter::REST::Response::ParseJson
- Twitter::REST::Response::RaiseError
- Twitter::REST::SavedSearches
- Twitter::REST::Search
- Twitter::REST::SpamReporting
- Twitter::REST::SuggestedUsers
- Twitter::REST::Timelines
- Twitter::REST::Trends
- Twitter::REST::Tweets
- Twitter::REST::Undocumented
- Twitter::REST::Users
- Twitter::REST::Utils
- Twitter::RateLimit
- Twitter::Relationship
- Twitter::Request
- Twitter::SavedSearch
- Twitter::SearchResults
- Twitter::Settings
- Twitter::Size
- Twitter::SourceUser
- Twitter::Streaming
- Twitter::Streaming::Client
- Twitter::Streaming::Connection
- Twitter::Streaming::DeletedTweet
- Twitter::Streaming::Event
- Twitter::Streaming::FriendList
- Twitter::Streaming::MessageParser
- Twitter::Streaming::Response
- Twitter::Streaming::StallWarning
- Twitter::Suggestion
- Twitter::TargetUser
- Twitter::Token
- Twitter::Trend
- Twitter::TrendResults
- Twitter::Tweet
- Twitter::User
- Twitter::Utils
- Twitter::Utils::ClassMethods
- Twitter::Version

No matching classes.

# Twitter::REST::OAuth

### Public Instance Methods

bearer_token(options = {}) click to toggle source
Alias for: token
invalidate_token(access_token, options = {}) click to toggle source

Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials.

@see dev.twitter.com/docs/api/1.1/post/oauth2/invalidate_token @rate_limited No @authentication Required @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @param access_token [String, Twitter::Token] The bearer token to revoke. @param options [Hash] A customizable set of options. @return [Twitter::Token] The invalidated token. token_type should be nil.

    # File lib/twitter/rest/oauth.rb, line 42
    def invalidate_token(access_token, options = {})
      access_token = access_token.access_token if access_token.is_a?(Twitter::Token)
      options[:access_token] = access_token
      perform_with_object(:post, '/oauth2/invalidate_token', options, Twitter::Token)
    end

reverse_token() click to toggle source

Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials.

@see dev.twitter.com/docs/api/1.1/post/oauth2/invalidate_token @rate_limited No @authentication Required @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [String] The token string.

    # File lib/twitter/rest/oauth.rb, line 55
    def reverse_token
      conn = connection.dup
      conn.builder.swap(4, Twitter::REST::Response::ParseErrorJson)
      response = conn.post('/oauth/request_token?x_auth_mode=reverse_auth') do |request|
        request.headers[:authorization] = oauth_auth_header(:post, 'https://api.twitter.com/oauth/request_token', :x_auth_mode => 'reverse_auth').to_s
      end
      response.body
    end

token(options = {}) click to toggle source

Allows a registered application to obtain an OAuth 2 Bearer Token, which can be used to make API requests on an application's own behalf, without a user context.

Only one bearer token may exist outstanding for an application, and repeated requests to this method will yield the same already-existent token until it has been invalidated.

@see dev.twitter.com/docs/api/1.1/post/oauth2/token @rate_limited No @authentication Required @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Twitter::Token] The Bearer Token. token_type should be 'bearer'. @param options [Hash] A customizable set of options. @example Generate a Bearer Token

    client = Twitter::REST::Client.new(:consumer_key => "abc", :consumer_secret => 'def')
    bearer_token = client.token

    # File lib/twitter/rest/oauth.rb, line 26
    def token(options = {})
      options[:bearer_token_request] = true
      options[:grant_type] ||= 'client_credentials'
      perform_with_object(:post, '/oauth2/token', options, Twitter::Token)
    end

Also aliased as: bearer_token

[Validate]

Generated with the Darkfish Rdoc Generator 2.