Module: Restforce::Client::Authentication

Included in:
Restforce::Client
Defined in:
lib/restforce/client/authentication.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object

Public: Force an authentication



6
7
8
9
10
# File 'lib/restforce/client/authentication.rb', line 6

def authenticate!
  raise 'No authentication middleware present' unless authentication_middleware
  middleware = authentication_middleware.new nil, self, @options
  middleware.authenticate!
end

#authentication_middlewareObject

Internal: Determines what middleware will be used based on the options provided



13
14
15
16
17
18
19
# File 'lib/restforce/client/authentication.rb', line 13

def authentication_middleware
  if username_password?
    Restforce::Middleware::Authentication::Password
  elsif oauth_refresh?
    Restforce::Middleware::Authentication::Token
  end
end

#oauth_refresh?Boolean

Internal: Returns true if oauth token refresh flow should be used for authentication.

Returns:

  • (Boolean)


32
33
34
35
36
# File 'lib/restforce/client/authentication.rb', line 32

def oauth_refresh?
  @options[:refresh_token] &&
    @options[:client_id] &&
    @options[:client_secret]
end

#username_password?Boolean

Internal: Returns true if username/password (autonomous) flow should be used for authentication.

Returns:

  • (Boolean)


23
24
25
26
27
28
# File 'lib/restforce/client/authentication.rb', line 23

def username_password?
  @options[:username] &&
    @options[:password] &&
    @options[:client_id] &&
    @options[:client_secret]
end