Module: SalesforceChatter::Authentication

Included in:
API
Defined in:
lib/salesforce-chatter/authentication.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/salesforce-chatter/authentication.rb', line 5

def authenticate(options={})
  options[:client_id]     = SalesforceChatter.consumer_key
  options[:client_secret] = SalesforceChatter.consumer_secret
  options[:username]      = SalesforceChatter.username
  options[:password]      = SalesforceChatter.password + SalesforceChatter.security_token
  options[:grant_type]    = 'password'

  response = post('services/oauth2/token', options)
  SalesforceChatter.oauth_token = response.access_token
  response
end

#authenticated?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/salesforce-chatter/authentication.rb', line 27

def authenticated?
  !SalesforceChatter.oauth_token.nil?
end

#authenticationObject



18
19
20
21
22
23
24
25
# File 'lib/salesforce-chatter/authentication.rb', line 18

def authentication
  {
    :consumer_key => consumer_key,
    :consumer_secret => consumer_secret,
    :token => oauth_token,
    :token_secret => oauth_token_secret
  }
end