Class: OmniAuth::Strategies::Yammer

Inherits:
OAuth
  • Object
show all
Defined in:
lib/omniauth/strategies/yammer.rb

Instance Attribute Summary

Attributes inherited from OAuth

#consumer_key, #consumer_options, #consumer_secret, #name

Instance Method Summary collapse

Methods inherited from OAuth

#callback_phase, #consumer, #request_phase, #unique_id

Constructor Details

#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Yammer

Returns a new instance of Yammer.



7
8
9
10
11
12
13
14
15
16
# File 'lib/omniauth/strategies/yammer.rb', line 7

def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
  client_options = {
    :site => 'https://www.yammer.com',
    :request_token_path => '/oauth/request_token',
    :access_token_path => '/oauth/access_token',
    :authorize_path => "/oauth/authorize"
  }

  super(app, :yammer, consumer_key, consumer_secret, client_options, options)
end

Instance Method Details

#auth_hashObject



18
19
20
21
22
23
24
# File 'lib/omniauth/strategies/yammer.rb', line 18

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

#user_hashObject



38
39
40
# File 'lib/omniauth/strategies/yammer.rb', line 38

def user_hash
  @user_hash ||= MultiJson.decode(@access_token.get('/api/v1/users/current.json').body)
end

#user_infoObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/omniauth/strategies/yammer.rb', line 26

def 
  user_hash = self.user_hash
  {
    'nickname' => user_hash['name'],
    'name' => user_hash['full-name'],
    'location' => user_hash['location'],
    'image' => user_hash['mugshot-url'],
    'description' => user_hash['job-title'],
    'urls' => {'Yammer' => user_hash['web-url']}
  }
end