Sha256: ec0a0d8cc43ebc56407f517b1869ccd1299ce3acc8f6133bbc811e43e743dd99
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require 'omniauth/oauth' require 'multi_json' module OmniAuth module Strategies class Yammer < OmniAuth::Strategies::OAuth def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) client_options = { :access_token_path => '/oauth/access_token', :authorize_path => '/oauth/authorize', :request_token_path => '/oauth/request_token', :site => 'https://www.yammer.com', } super(app, :yammer, consumer_key, consumer_secret, client_options, options, &block) end def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_hash['id'], 'user_info' => user_info, 'extra' => { 'user_hash' => user_hash, }, } ) end def user_info 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 def user_hash @user_hash ||= MultiJson.decode(@access_token.get('/api/v1/users/current.json').body) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
oa-oauth-0.3.0.rc3 | lib/omniauth/strategies/oauth/yammer.rb |