Sha256: 50f0dc10fee6529a9fb1486d2923b028335426dc35d963b89fa9a73153930439
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
require 'omniauth/oauth' require 'multi_json' module OmniAuth module Strategies class Teambox < OmniAuth::Strategies::OAuth2 def initialize(app, client_id=nil, client_secret=nil, options={}, &block) client_options = { :authorize_url => 'https://teambox.com/oauth/authorize', :token_url => 'https://teambox.com/oauth/token', } super(app, :teambox, client_id, client_secret, client_options, options, &block) end def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data['id'], 'user_info' => user_info, 'extra' => { 'user_hash' => user_data }, } ) end def request_phase options[:scope] ||= 'offline_access' options[:response_type] ||= 'code' super end def callback_phase options[:grant_type] ||= 'authorization_code' super end def user_data @data ||= MultiJson.decode(@access_token.get('/api/1/account')) end def user_info { 'nickname' => user_data['username'], 'name' => user_data['first_name'], 'image' => user_data['avatar_url'], } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oa-oauth-0.3.2 | lib/omniauth/strategies/oauth2/teambox.rb |
oa-oauth-0.3.0 | lib/omniauth/strategies/oauth2/teambox.rb |
oa-oauth-0.3.0.rc3 | lib/omniauth/strategies/oauth2/teambox.rb |