Class: OmniAuth::Strategies::Salesforce
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Salesforce
show all
- Defined in:
- lib/omniauth/strategies/oauth2/salesforce.rb
Instance Attribute Summary
Attributes inherited from OAuth2
#client_id, #client_options, #client_secret, #options
Instance Method Summary
collapse
Methods inherited from OAuth2
#callback_url, #client
Constructor Details
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Salesforce
Returns a new instance of Salesforce.
6
7
8
9
10
11
12
13
|
# File 'lib/omniauth/strategies/oauth2/salesforce.rb', line 6
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
client_options = {
:site => 'https://login.salesforce.com',
:authorize_url => '/services/oauth2/authorize',
:token_url => '/services/oauth2/token',
}
super(app, :salesforce, client_id, client_secret, client_options, options, &block)
end
|
Instance Method Details
#auth_hash ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/omniauth/strategies/oauth2/salesforce.rb', line 25
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
|
#callback_phase ⇒ Object
20
21
22
23
|
# File 'lib/omniauth/strategies/oauth2/salesforce.rb', line 20
def callback_phase
options[:grant_type] ||= 'authorization_code'
super
end
|
#request_phase ⇒ Object
15
16
17
18
|
# File 'lib/omniauth/strategies/oauth2/salesforce.rb', line 15
def request_phase
options[:response_type] ||= 'code'
super
end
|
#user_data ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/omniauth/strategies/oauth2/salesforce.rb', line 47
def user_data
@access_token.options[:header_format] = 'OAuth %s'
@data ||= @access_token.get(@access_token['id']).parsed
rescue ::OAuth2::Error => e
if e.response.status == 302
@data ||= @access_token.get(e.response.['location']).parsed
else
raise e
end
end
|