Module: Twitter::REST::OAuth
Constant Summary
Constants included from Utils
Instance Method Summary collapse
-
#invalidate_token(access_token, options = {}) ⇒ String
Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials.
-
#reverse_token ⇒ String
Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials.
-
#token(options = {}) ⇒ String
(also: #bearer_token)
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.
Methods included from Utils
Instance Method Details
#invalidate_token(access_token, options = {}) ⇒ String
Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials.
44 45 46 47 48 |
# File 'lib/twitter/rest/oauth.rb', line 44 def invalidate_token(access_token, = {}) = .dup [:access_token] = access_token perform_post("/oauth2/invalidate_token", )[:access_token] end |
#reverse_token ⇒ String
Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials.
57 58 59 60 61 62 |
# File 'lib/twitter/rest/oauth.rb', line 57 def reverse_token = {x_auth_mode: "reverse_auth"} url = "https://api.twitter.com/oauth/request_token" auth_header = Twitter::Headers.new(self, :post, url, ).oauth_auth_header.to_s HTTP.headers(authorization: auth_header).post(url, params: ).to_s end |
#token(options = {}) ⇒ String Also known as: bearer_token
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.
24 25 26 27 28 29 30 31 32 |
# File 'lib/twitter/rest/oauth.rb', line 24 def token( = {}) = .dup [:bearer_token_request] = true [:grant_type] ||= "client_credentials" url = "https://api.twitter.com/oauth2/token" headers = Twitter::Headers.new(self, :post, url, ).request_headers response = HTTP.headers(headers).post(url, form: ) response.parse["access_token"] end |