Module: AuthTool::OAuth1
- Defined in:
- lib/auth_tool/oauth_1.rb
Class Method Summary collapse
-
.call(client, http_verb = 'get', uri, params) ⇒ Hash
Makes an authenticated call to the API resource.
-
.receive(client, response) ⇒ Object
Handles OAuth 1.0 callback procedure.
-
.redirect_url(client, options = {}) ⇒ String
Returns redirect url for user authentication with the service.
Class Method Details
.call(client, http_verb = 'get', uri, params) ⇒ Hash
Makes an authenticated call to the API resource. Called by AuthTool::call.
62 63 64 65 66 67 68 69 |
# File 'lib/auth_tool/oauth_1.rb', line 62 def self.call(client, http_verb = 'get', uri, params) header = params.delete('header') if params.has_key? 'header' body = params.delete('body') if params.has_key? 'body' conn = Faraday.new(:params => params) = {:method => http_verb, :header => header, :body => body, :uri => uri, :connection => conn} response = client.signet.fetch_protected_resource() return JSON.parse(response.body) end |
.receive(client, response) ⇒ Object
Handles OAuth 1.0 callback procedure. Called by AuthTool::receive.
41 42 43 44 45 46 |
# File 'lib/auth_tool/oauth_1.rb', line 41 def self.receive(client, response) verifier = response['oauth_verifier'] if response.has_key?('oauth_verifier') verifier = response[:oauth_verifier] if response.has_key?(:oauth_verifier) credential = client.signet.fetch_token_credential!(:verifier => verifier) client.token = credential.to_hash end |
.redirect_url(client, options = {}) ⇒ String
Returns redirect url for user authentication with the service
26 27 28 29 30 |
# File 'lib/auth_tool/oauth_1.rb', line 26 def self.redirect_url(client, = {}) client.signet.fetch_temporary_credential!() url = client.signet. return url end |