oa-oauth 0.2.0.beta3 → 0.2.0.beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/omniauth/oauth.rb +1 -0
- data/lib/omniauth/strategies/google.rb +3 -1
- data/lib/omniauth/strategies/hyves.rb +67 -0
- metadata +5 -4
data/lib/omniauth/oauth.rb
CHANGED
@@ -20,6 +20,8 @@ module OmniAuth
|
|
20
20
|
:authorize_path => '/accounts/OAuthAuthorizeToken'
|
21
21
|
}
|
22
22
|
|
23
|
+
options[:scope] ||= "http://www.google.com/m8/feeds"
|
24
|
+
|
23
25
|
super(app, :google, consumer_key, consumer_secret, client_options, options)
|
24
26
|
end
|
25
27
|
|
@@ -58,7 +60,7 @@ module OmniAuth
|
|
58
60
|
|
59
61
|
# Monkeypatch OmniAuth to pass the scope in the consumer.get_request_token call
|
60
62
|
def request_phase
|
61
|
-
request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope =>
|
63
|
+
request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => options[:scope]})
|
62
64
|
|
63
65
|
(session['oauth']||={})[name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
|
64
66
|
r = Rack::Response.new
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class Hyves < OmniAuth::Strategies::OAuth
|
8
|
+
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
9
|
+
client_options = {
|
10
|
+
:request_token_path => request_token_path,
|
11
|
+
:authorize_path => "http://www.hyves.nl/api/authorize",
|
12
|
+
:access_token_path => access_token_path,
|
13
|
+
:http_method => :get,
|
14
|
+
:scheme => :header
|
15
|
+
}
|
16
|
+
super(app, :hyves, consumer_key, consumer_secret, client_options, options, &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def auth_hash
|
20
|
+
hash = user_hash(@access_token)
|
21
|
+
|
22
|
+
{
|
23
|
+
"provider" => "hyves",
|
24
|
+
"uid" => hash["userid"],
|
25
|
+
"user_info" => {
|
26
|
+
"name" => hash["firstname"] + " " + hash["lastname"],
|
27
|
+
"first_name" => hash["firstname"],
|
28
|
+
"last_name" => hash["lastname"]
|
29
|
+
},
|
30
|
+
"credentials" => {
|
31
|
+
"token" => @access_token.token,
|
32
|
+
"secret" => @access_token.secret
|
33
|
+
}
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def user_hash(access_token)
|
38
|
+
rsp = MultiJson.decode( access_token.get("http://data.hyves-api.nl/?userid=#{access_token.params[:userid]}&ha_method=users.get&#{default_options}").body )
|
39
|
+
rsp["user"].first
|
40
|
+
end
|
41
|
+
|
42
|
+
def request_token_path
|
43
|
+
"http://data.hyves-api.nl/?#{request_token_options}&#{default_options}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def access_token_path
|
47
|
+
"http://data.hyves-api.nl/?#{access_token_options}&#{default_options}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def default_options
|
51
|
+
to_params( { :ha_version => "2.0", :ha_format => "json", :ha_fancylayout => false } )
|
52
|
+
end
|
53
|
+
|
54
|
+
def request_token_options
|
55
|
+
to_params( { :methods => "users.get,friends.get,wwws.create", :ha_method => "auth.requesttoken", :strict_oauth_spec_response => true } )
|
56
|
+
end
|
57
|
+
|
58
|
+
def access_token_options
|
59
|
+
to_params( { :ha_method => "auth.accesstoken", :strict_oauth_spec_response => true } )
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_params(options)
|
63
|
+
options.collect { |key, value| "#{key}=#{value}"}.join('&')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: oa-oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 0.2.0.
|
5
|
+
version: 0.2.0.beta4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Michael Bleigh
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-02-
|
13
|
+
date: 2011-02-11 00:00:00 -06:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.2.0.
|
23
|
+
version: 0.2.0.beta4
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: *id001
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- lib/omniauth/strategies/goodreads.rb
|
153
153
|
- lib/omniauth/strategies/google.rb
|
154
154
|
- lib/omniauth/strategies/gowalla.rb
|
155
|
+
- lib/omniauth/strategies/hyves.rb
|
155
156
|
- lib/omniauth/strategies/identica.rb
|
156
157
|
- lib/omniauth/strategies/linked_in.rb
|
157
158
|
- lib/omniauth/strategies/meetup.rb
|
@@ -183,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
184
|
requirements:
|
184
185
|
- - ">="
|
185
186
|
- !ruby/object:Gem::Version
|
186
|
-
hash:
|
187
|
+
hash: 3188666288228867303
|
187
188
|
segments:
|
188
189
|
- 0
|
189
190
|
version: "0"
|