Class: OmniAuth::Strategies::Hyves
- Defined in:
- lib/omniauth/strategies/oauth/hyves.rb
Instance Attribute Summary
Attributes inherited from OAuth
#consumer_key, #consumer_options, #consumer_secret, #name
Instance Method Summary collapse
- #access_token_options ⇒ Object
- #access_token_path ⇒ Object
- #auth_hash ⇒ Object
- #default_options ⇒ Object
-
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Hyves
constructor
A new instance of Hyves.
- #request_token_path(options) ⇒ Object
- #to_params(options) ⇒ Object
- #user_hash(access_token) ⇒ Object
Methods inherited from OAuth
#callback_phase, #consumer, #request_phase, #unique_id
Constructor Details
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Hyves
Returns a new instance of Hyves.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/omniauth/strategies/oauth/hyves.rb', line 7 def initialize(app, consumer_key=nil, consumer_secret=nil, ={}, &block) = { :methods => 'users.get,friends.get,wwws.create', :expirationtype => 'default' }.merge() = { :authorize_path => 'http://www.hyves.nl/api/authorize', :access_token_path => access_token_path, :http_method => :get, :request_token_path => request_token_path(), :scheme => :header, } super(app, :hyves, consumer_key, consumer_secret, , , &block) end |
Instance Method Details
#access_token_options ⇒ Object
60 61 62 |
# File 'lib/omniauth/strategies/oauth/hyves.rb', line 60 def to_params({:ha_method => 'auth.accesstoken', :strict_oauth_spec_response => true}) end |
#access_token_path ⇒ Object
52 53 54 |
# File 'lib/omniauth/strategies/oauth/hyves.rb', line 52 def access_token_path "http://data.hyves-api.nl/?#{}&#{}" end |
#auth_hash ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/omniauth/strategies/oauth/hyves.rb', line 24 def auth_hash hash = user_hash(@access_token) { 'provider' => 'hyves', 'uid' => hash['userid'], 'user_info' => { 'name' => "#{hash['firstname']} #{hash['lastname']}", 'first_name' => hash['firstname'], 'last_name' => hash['lastname'], }, 'credentials' => { 'token' => @access_token.token, 'secret' => @access_token.secret, }, } end |
#default_options ⇒ Object
56 57 58 |
# File 'lib/omniauth/strategies/oauth/hyves.rb', line 56 def to_params({:ha_version => '2.0', :ha_format => 'json', :ha_fancylayout => false}) end |
#request_token_path(options) ⇒ Object
46 47 48 49 50 |
# File 'lib/omniauth/strategies/oauth/hyves.rb', line 46 def request_token_path() ['ha_method'] = 'auth.requesttoken' ['strict_oauth_spec_response'] = true "http://data.hyves-api.nl/?#{to_params()}&#{}" end |
#to_params(options) ⇒ Object
64 65 66 |
# File 'lib/omniauth/strategies/oauth/hyves.rb', line 64 def to_params() .collect{|key, value| "#{key}=#{value}"}.join('&') end |
#user_hash(access_token) ⇒ Object
41 42 43 44 |
# File 'lib/omniauth/strategies/oauth/hyves.rb', line 41 def user_hash(access_token) rsp = MultiJson.decode(access_token.get("http://data.hyves-api.nl/?userid=#{access_token.params[:userid]}&ha_method=users.get&#{}").body) rsp['user'].first end |