Class: OmniAuth::Strategies::Salesforce
- Defined in:
- lib/omniauth/strategies/salesforce.rb
Instance Attribute Summary
Attributes inherited from OAuth2
#client_id, #client_options, #client_secret, #options
Instance Method Summary collapse
- #auth_hash ⇒ Object
-
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Salesforce
constructor
A new instance of Salesforce.
- #user_data ⇒ Object
Methods inherited from OAuth2
Constructor Details
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Salesforce
Returns a new instance of Salesforce.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/omniauth/strategies/salesforce.rb', line 6 def initialize(app, consumer_key = nil, consumer_secret = nil, = {}, &block) = { :site => 'https://login.salesforce.com', :authorize_path => '/services/oauth2/authorize', :access_token_path => '/services/oauth2/token' } .merge!(:response_type => 'code', :grant_type => 'authorization_code') super(app, :salesforce, consumer_key, consumer_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/omniauth/strategies/salesforce.rb', line 18 def auth_hash data = user_data OmniAuth::Utils.deep_merge(super, { 'uid' => @access_token['id'], 'credentials' => { 'instance_url' => @access_token['instance_url'] }, 'extra' => {'user_hash' => data}, 'user_info' => { 'email' => data['email'], 'name' => data['display_name'] } }) end |
#user_data ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/omniauth/strategies/salesforce.rb', line 33 def user_data @data ||= MultiJson.decode(@access_token.get(@access_token['id'])) rescue ::OAuth2::HTTPError => e if e.response.status == 302 @data ||= MultiJson.decode(@access_token.get(e.response.headers['location'])) else raise e end end |