Sha256: abb7eea3271921e36343d271dcf8544845cf9f564ed9e8d38383a6090e84bc00

Contents?: true

Size: 768 Bytes

Versions: 7

Compression:

Stored size: 768 Bytes

Contents

module Restforce

  # Authentication middleware used if oauth_token and refresh_token are set
  class Middleware::Authentication::Token < Restforce::Middleware::Authentication

    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, error_message(response) if response.status != 200
      @options[:instance_url] = response.body['instance_url']
      @options[:oauth_token]  = response.body['access_token']
    end
  
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
restforce-0.1.1 lib/restforce/middleware/authentication/token.rb
restforce-0.1.0 lib/restforce/middleware/authentication/token.rb
restforce-0.0.8 lib/restforce/middleware/authentication/token.rb
restforce-0.0.7 lib/restforce/middleware/authentication/token.rb
restforce-0.0.6 lib/restforce/middleware/authentication/token.rb
restforce-0.0.5 lib/restforce/middleware/authentication/token.rb
restforce-0.0.4 lib/restforce/middleware/authentication/token.rb