Class: Restforce::Middleware::Authentication::Token
- Inherits:
-
Restforce::Middleware::Authentication
- Object
- Faraday::Middleware
- Restforce::Middleware
- Restforce::Middleware::Authentication
- Restforce::Middleware::Authentication::Token
- Defined in:
- lib/restforce/middleware/authentication/token.rb
Overview
Authentication middleware used if oauth_token and refresh_token are set
Instance Method Summary collapse
Methods inherited from Restforce::Middleware::Authentication
#call, #connection, #error_message, #force_authenticate?
Methods inherited from Restforce::Middleware
#client, #connection, #initialize
Constructor Details
This class inherits a constructor from Restforce::Middleware
Instance Method Details
#authenticate! ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/restforce/middleware/authentication/token.rb', line 6 def authenticate! response = connection.post '/services/oauth2/token' do |req| req.body = URI.encode_www_form( :grant_type => 'refresh_token', :refresh_token => @options[:refresh_token], :client_id => @options[:client_id], :client_secret => @options[:client_secret] ) end raise Restforce::AuthenticationError, (response) if response.status != 200 @options[:instance_url] = response.body['instance_url'] @options[:oauth_token] = response.body['access_token'] end |