Sha256: b4892674d0bd91ae974ae79b10e04c75777fe060ce89c77182fd32ac8dd6fd86
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
require 'omniauth/strategies/oauth2' module OmniAuth module Strategies class Salesforce < OmniAuth::Strategies::OAuth2 def initialize(app, client_id=nil, client_secret=nil, options={}, &block) client_options = { :authorize_url => 'https://login.salesforce.com/services/oauth2/authorize', :token_url => 'https://login.salesforce.com/services/oauth2/token', } options.merge!(:response_type => 'code', :grant_type => 'authorization_code') super(app, :salesforce, client_id, client_secret, client_options, options, &block) end def auth_hash data = user_data OmniAuth::Utils.deep_merge( super, { 'uid' => @access_token['id'], 'credentials' => { 'issued_at' => @access_token['issued_at'], 'refresh_token' => @access_token.refresh_token, 'instance_url' => @access_token['instance_url'], 'signature' => @access_token['signature'], }, 'extra' => { 'user_hash' => data, }, 'user_info' => { 'email' => data['email'], 'name' => data['display_name'], }, } ) end def user_data @data ||= MultiJson.decode(@access_token.get(@access_token['id'])) rescue ::OAuth2::Error => e if e.response.status == 302 @data ||= MultiJson.decode(@access_token.get(e.response.headers['location'])) else raise e end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
oa-oauth-0.3.0 | lib/omniauth/strategies/oauth2/salesforce.rb |
oa-oauth-0.3.0.rc3 | lib/omniauth/strategies/oauth2/salesforce.rb |