Sha256: 9beafcb0b63b397707901aef10b51540c2765d6f9d009ed0ebfa347eb229e237
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
require 'omniauth/oauth' require 'multi_json' module OmniAuth module Strategies # Authenticate to Dopplr via OAuth and retrieve an access token for API usage # # Usage: # use OmniAuth::Strategies::Dopplr, 'consumerkey', 'consumersecret' class Dopplr < OmniAuth::Strategies::OAuth # Initialize the Dopplr strategy. # # @option options [Hash, {}] :client_options Options to be passed directly to the OAuth Consumer 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.dopplr.com', } super(app, :dopplr, consumer_key, consumer_secret, client_options, options, &block) end def user_data @data ||= MultiJson.decode(@access_token.get('/oauthapi/whoami').body)['whoami'] end def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data['nick'], 'user_info' => user_info, } ) end def user_info { 'nickname' => user_data['nick'], 'first_name' => user_data['forename'], 'last_name' => user_data['surname'], 'name' => "#{user_data['forename']} #{user_data['surname']}", 'urls' => { 'Dopplr' => user_data['dopplr_url'], 'DopplrMobile' => user_data['mobile_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/oauth/dopplr.rb |
oa-oauth-0.3.0 | lib/omniauth/strategies/oauth/dopplr.rb |
oa-oauth-0.3.0.rc3 | lib/omniauth/strategies/oauth/dopplr.rb |