Module: Pardot::Authentication

Included in:
Client
Defined in:
lib/pardot/authentication.rb

Instance Method Summary collapse

Instance Method Details

#authenticateObject

Deprecated.

Use of username and password authentication is deprecated.



4
5
6
7
8
9
10
11
12
13
# File 'lib/pardot/authentication.rb', line 4

def authenticate
  if using_salesforce_access_token?
    raise 'Authentication not available when using Salesforce access token. See https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_oauth_and_connected_apps.htm for more information.'
  end

  warn '[DEPRECATION] Use of username and password authentication is deprecated in favor of Salesforce OAuth. See https://developer.pardot.com/kb/authentication/ for more information.'
  resp = post 'login', nil, nil, nil, email: @email, password: @password, user_key: @user_key
  update_version(resp['version']) if resp && resp['version']
  @api_key = resp && resp['api_key']
end

#authenticated?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/pardot/authentication.rb', line 15

def authenticated?
  !@api_key.nil? || !@salesforce_access_token.nil?
end

#reauthenticateObject



23
24
25
26
27
28
29
30
31
# File 'lib/pardot/authentication.rb', line 23

def reauthenticate
  if using_salesforce_access_token?
    raise 'Reauthentication not available when using Salesforce access token. See https://developer.salesforce.com/docs/atlas.en-us.mobile_sdk.meta/mobile_sdk/oauth_refresh_token_flow.htm for more information.'
  end

  warn '[DEPRECATION] Use Salesforce OAuth to refresh the Salesforce access token. See https://developer.salesforce.com/docs/atlas.en-us.mobile_sdk.meta/mobile_sdk/oauth_refresh_token_flow.htm for more information.'
  @api_key = nil
  authenticate
end

#using_salesforce_access_token?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/pardot/authentication.rb', line 19

def using_salesforce_access_token?
  @salesforce_access_token != nil
end