Class: OmniAuth::Strategies::Hyves
- Inherits:
-
OAuth
- Object
- OAuth
- OmniAuth::Strategies::Hyves
show all
- Defined in:
- lib/omniauth/strategies/hyves.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) ⇒ Hyves
Returns a new instance of Hyves.
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/omniauth/strategies/hyves.rb', line 8
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
client_options = {
:request_token_path => request_token_path,
:authorize_path => "http://www.hyves.nl/api/authorize",
:access_token_path => access_token_path,
:http_method => :get,
:scheme => :header
}
super(app, :hyves, consumer_key, consumer_secret, client_options, options, &block)
end
|
Instance Method Details
#access_token_options ⇒ Object
58
59
60
|
# File 'lib/omniauth/strategies/hyves.rb', line 58
def access_token_options
to_params( { :ha_method => "auth.accesstoken", :strict_oauth_spec_response => true } )
end
|
#access_token_path ⇒ Object
46
47
48
|
# File 'lib/omniauth/strategies/hyves.rb', line 46
def access_token_path
"http://data.hyves-api.nl/?#{access_token_options}&#{default_options}"
end
|
#auth_hash ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/omniauth/strategies/hyves.rb', line 19
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
50
51
52
|
# File 'lib/omniauth/strategies/hyves.rb', line 50
def default_options
to_params( { :ha_version => "2.0", :ha_format => "json", :ha_fancylayout => false } )
end
|
#request_token_options ⇒ Object
54
55
56
|
# File 'lib/omniauth/strategies/hyves.rb', line 54
def request_token_options
to_params( { :methods => "users.get,friends.get,wwws.create", :ha_method => "auth.requesttoken", :strict_oauth_spec_response => true } )
end
|
#request_token_path ⇒ Object
42
43
44
|
# File 'lib/omniauth/strategies/hyves.rb', line 42
def request_token_path
"http://data.hyves-api.nl/?#{request_token_options}&#{default_options}"
end
|
#to_params(options) ⇒ Object
62
63
64
|
# File 'lib/omniauth/strategies/hyves.rb', line 62
def to_params(options)
options.collect { |key, value| "#{key}=#{value}"}.join('&')
end
|
#user_hash(access_token) ⇒ Object
37
38
39
40
|
# File 'lib/omniauth/strategies/hyves.rb', line 37
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&#{default_options}").body )
rsp["user"].first
end
|