Class: OmniAuth::Strategies::ThirtySevenSignals

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/oauth2/thirty_seven_signals.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) ⇒ ThirtySevenSignals

Returns a new instance of ThirtySevenSignals.



7
8
9
10
11
12
13
# File 'lib/omniauth/strategies/oauth2/thirty_seven_signals.rb', line 7

def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
  client_options = {
    :authorize_url => 'https://launchpad.37signals.com/authorization/new',
    :token_url => 'https://launchpad.37signals.com/authorization/token',
  }
  super(app, :thirty_seven_signals, client_id, client_secret, client_options, options, &block)
end

Instance Method Details

#auth_hashObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/omniauth/strategies/oauth2/thirty_seven_signals.rb', line 15

def auth_hash
  OmniAuth::Utils.deep_merge(
    super, {
      'uid' => user_data['identity']['id'],
      'user_info' => ,
      'extra' => {
        'accounts' => user_data['accounts'],
      }
    }
  )
end

#user_dataObject



27
28
29
# File 'lib/omniauth/strategies/oauth2/thirty_seven_signals.rb', line 27

def user_data
  @data ||= @access_token.get('https://launchpad.37signals.com/authorization.json').parsed
end

#user_infoObject



31
32
33
34
35
36
37
38
# File 'lib/omniauth/strategies/oauth2/thirty_seven_signals.rb', line 31

def 
  {
    'email' => user_data['identity']['email_address'],
    'first_name' => user_data['identity']['first_name'],
    'last_name' => user_data['identity']['last_name'],
    'name' => [user_data['identity']['first_name'], user_data['identity']['last_name']].join(' ').strip,
  }
end