Class: OmniAuth::Strategies::Forcedotcom
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Forcedotcom
- Defined in:
- lib/Salesforce/oauth2/forcedotcom.rb
Instance Method Summary collapse
- #auth_hash ⇒ Object
-
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Forcedotcom
constructor
A new instance of Forcedotcom.
- #user_data ⇒ Object
Constructor Details
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Forcedotcom
Returns a new instance of Forcedotcom.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/Salesforce/oauth2/forcedotcom.rb', line 9 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' } # 'code' locks you into one org; 'token' works across all orgs. .merge!(:response_type => 'token', :grant_type => 'authorization_code') super(app, :forcedotcom, consumer_key, consumer_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/Salesforce/oauth2/forcedotcom.rb', line 22 def auth_hash data = user_data OmniAuth::Utils.deep_merge(super, { 'uid' => @access_token['id'], 'credentials' => { 'instance_url' => @access_token['instance_url'], 'credentials' => {"refresh_token" => @access_token.refresh_token, "consumer_key" => @access_token.client.id, "consumer_secret" => @access_token.client.secret } }, 'extra' => {'user_hash' => data}, 'user_info' => { 'email' => data['email'], 'name' => data['display_name'] } }) end |
#user_data ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/Salesforce/oauth2/forcedotcom.rb', line 61 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 |