oa-oauth 0.2.0.beta2 → 0.2.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
data/lib/omniauth/oauth.rb
CHANGED
@@ -4,7 +4,7 @@ module OmniAuth
|
|
4
4
|
module Strategies
|
5
5
|
autoload :OAuth, 'omniauth/strategies/oauth'
|
6
6
|
autoload :OAuth2, 'omniauth/strategies/oauth2'
|
7
|
-
|
7
|
+
|
8
8
|
autoload :Twitter, 'omniauth/strategies/twitter'
|
9
9
|
autoload :LinkedIn, 'omniauth/strategies/linked_in'
|
10
10
|
autoload :Facebook, 'omniauth/strategies/facebook'
|
@@ -24,5 +24,7 @@ module OmniAuth
|
|
24
24
|
autoload :Google, 'omniauth/strategies/google'
|
25
25
|
autoload :Netflix, 'omniauth/strategies/netflix'
|
26
26
|
autoload :Bitly, 'omniauth/strategies/bitly'
|
27
|
+
autoload :Vimeo, 'omniauth/strategies/vimeo'
|
28
|
+
autoload :YouTube, 'omniauth/strategies/you_tube'
|
27
29
|
end
|
28
30
|
end
|
@@ -52,10 +52,6 @@ module OmniAuth
|
|
52
52
|
'nickname' => user['nickname'],
|
53
53
|
'first_name' => user['first_name'],
|
54
54
|
'last_name' => user['last_name'],
|
55
|
-
'can_instant_watch' => user['can_instant_watch'],
|
56
|
-
'link' => user['link'],
|
57
|
-
'max_maturity_level' => user['max_maturity_level'],
|
58
|
-
'preferred_formats' => user['preferred_formats']
|
59
55
|
}
|
60
56
|
end
|
61
57
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
#
|
7
|
+
# Authenticate to Vimeo via OAuth and retrieve basic user information.
|
8
|
+
#
|
9
|
+
# Usage:
|
10
|
+
#
|
11
|
+
# use OmniAuth::Strategies::Vimeo, 'consumerkey', 'consumersecret'
|
12
|
+
#
|
13
|
+
class Vimeo < OmniAuth::Strategies::OAuth
|
14
|
+
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
15
|
+
opts = {
|
16
|
+
:site => 'http://vimeo.com',
|
17
|
+
:request_token_path => '/oauth/request_token',
|
18
|
+
:access_token_path => '/oauth/access_token',
|
19
|
+
:authorize_path => '/oauth/authorize'
|
20
|
+
}
|
21
|
+
super(app, :vimeo, consumer_key, consumer_secret, opts, options, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def auth_hash
|
25
|
+
user = user_hash['person']
|
26
|
+
OmniAuth::Utils.deep_merge(super, {
|
27
|
+
'uid' => user['id'],
|
28
|
+
'user_info' => user_info,
|
29
|
+
'extra' => { 'user_hash' => user }
|
30
|
+
})
|
31
|
+
end
|
32
|
+
|
33
|
+
def user_info
|
34
|
+
user = user_hash['person']
|
35
|
+
{
|
36
|
+
'nickname' => user['username'],
|
37
|
+
'name' => user['display_name'],
|
38
|
+
'location' => user['location'],
|
39
|
+
'description' => user['bio'],
|
40
|
+
'image' => user['portraits']['portrait'].select{|h| h['height'] == '300'}.first['_content'],
|
41
|
+
'urls' => {
|
42
|
+
'website' => user['url'],
|
43
|
+
'vimeo' => user['profileurl']
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def user_hash
|
49
|
+
url = "http://vimeo.com/api/rest/v2?method=vimeo.people.getInfo&format=json"
|
50
|
+
@user_hash ||= MultiJson.decode(@access_token.get(url).body)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Based heavily on the Google strategy, monkeypatch and all
|
2
|
+
|
3
|
+
require 'omniauth/oauth'
|
4
|
+
require 'multi_json'
|
5
|
+
|
6
|
+
module OmniAuth
|
7
|
+
module Strategies
|
8
|
+
#
|
9
|
+
# Authenticate to YouTube via OAuth and retrieve basic user info.
|
10
|
+
#
|
11
|
+
# Usage:
|
12
|
+
#
|
13
|
+
# use OmniAuth::Strategies::YouTube, 'consumerkey', 'consumersecret'
|
14
|
+
#
|
15
|
+
class YouTube < OmniAuth::Strategies::OAuth
|
16
|
+
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
17
|
+
client_options = {
|
18
|
+
:site => 'https://www.google.com',
|
19
|
+
:request_token_path => '/accounts/OAuthGetRequestToken',
|
20
|
+
:access_token_path => '/accounts/OAuthGetAccessToken',
|
21
|
+
:authorize_path => '/accounts/OAuthAuthorizeToken'
|
22
|
+
}
|
23
|
+
|
24
|
+
super(app, :you_tube, consumer_key, consumer_secret, client_options, options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def auth_hash
|
28
|
+
ui = user_info
|
29
|
+
OmniAuth::Utils.deep_merge(super, {
|
30
|
+
'uid' => ui['uid'],
|
31
|
+
'user_info' => ui,
|
32
|
+
'extra' => {'user_hash' => user_hash}
|
33
|
+
})
|
34
|
+
end
|
35
|
+
|
36
|
+
def user_info
|
37
|
+
entry = user_hash['entry']
|
38
|
+
{
|
39
|
+
'uid' => entry['id']['$t'],
|
40
|
+
'nickname' => entry['author'].first['name']['$t'],
|
41
|
+
'first_name' => entry['yt$firstName'] && entry['yt$firstName']['$t'],
|
42
|
+
'last_name' => entry['yt$lastName'] && entry['yt$lastName']['$t'],
|
43
|
+
'image' => entry['media$thumbnail'] && entry['media$thumbnail']['url'],
|
44
|
+
'description' => entry['yt$description'] && entry['yt$description']['$t'],
|
45
|
+
'location' => entry['yt$location'] && entry['yt$location']['$t']
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def user_hash
|
50
|
+
# YouTube treats 'default' as the currently logged-in user
|
51
|
+
# via http://apiblog.youtube.com/2010/11/update-to-clientlogin-url.html
|
52
|
+
@user_hash ||= MultiJson.decode(@access_token.get("http://gdata.youtube.com/feeds/api/users/default?alt=json").body)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Monkeypatch consumer.get_request_token but specify YouTube scope rather than Google Contacts
|
56
|
+
# TODO this is an easy patch to the underlying OAuth strategy a la OAuth2
|
57
|
+
def request_phase
|
58
|
+
request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => 'http://gdata.youtube.com'})
|
59
|
+
|
60
|
+
(session['oauth']||={})[name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
|
61
|
+
r = Rack::Response.new
|
62
|
+
|
63
|
+
if request_token.callback_confirmed?
|
64
|
+
r.redirect(request_token.authorize_url)
|
65
|
+
else
|
66
|
+
r.redirect(request_token.authorize_url(:oauth_callback => callback_url))
|
67
|
+
end
|
68
|
+
|
69
|
+
r.finish
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oa-oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 0
|
9
|
-
- beta2
|
10
|
-
version: 0.2.0.beta2
|
4
|
+
prerelease: 6
|
5
|
+
version: 0.2.0.beta3
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Michael Bleigh
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
13
|
+
date: 2011-02-03 00:00:00 -06:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,12 +20,7 @@ dependencies:
|
|
25
20
|
requirements:
|
26
21
|
- - "="
|
27
22
|
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
- 2
|
31
|
-
- 0
|
32
|
-
- beta2
|
33
|
-
version: 0.2.0.beta2
|
23
|
+
version: 0.2.0.beta3
|
34
24
|
type: :runtime
|
35
25
|
prerelease: false
|
36
26
|
version_requirements: *id001
|
@@ -41,10 +31,6 @@ dependencies:
|
|
41
31
|
requirements:
|
42
32
|
- - ~>
|
43
33
|
- !ruby/object:Gem::Version
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
- 0
|
47
|
-
- 2
|
48
34
|
version: 0.0.2
|
49
35
|
type: :runtime
|
50
36
|
prerelease: false
|
@@ -56,10 +42,6 @@ dependencies:
|
|
56
42
|
requirements:
|
57
43
|
- - ~>
|
58
44
|
- !ruby/object:Gem::Version
|
59
|
-
segments:
|
60
|
-
- 1
|
61
|
-
- 4
|
62
|
-
- 2
|
63
45
|
version: 1.4.2
|
64
46
|
type: :runtime
|
65
47
|
prerelease: false
|
@@ -71,10 +53,6 @@ dependencies:
|
|
71
53
|
requirements:
|
72
54
|
- - ~>
|
73
55
|
- !ruby/object:Gem::Version
|
74
|
-
segments:
|
75
|
-
- 0
|
76
|
-
- 4
|
77
|
-
- 0
|
78
56
|
version: 0.4.0
|
79
57
|
type: :runtime
|
80
58
|
prerelease: false
|
@@ -86,10 +64,6 @@ dependencies:
|
|
86
64
|
requirements:
|
87
65
|
- - ~>
|
88
66
|
- !ruby/object:Gem::Version
|
89
|
-
segments:
|
90
|
-
- 0
|
91
|
-
- 1
|
92
|
-
- 1
|
93
67
|
version: 0.1.1
|
94
68
|
type: :runtime
|
95
69
|
prerelease: false
|
@@ -101,8 +75,6 @@ dependencies:
|
|
101
75
|
requirements:
|
102
76
|
- - ">="
|
103
77
|
- !ruby/object:Gem::Version
|
104
|
-
segments:
|
105
|
-
- 0
|
106
78
|
version: "0"
|
107
79
|
type: :development
|
108
80
|
prerelease: false
|
@@ -114,10 +86,6 @@ dependencies:
|
|
114
86
|
requirements:
|
115
87
|
- - ~>
|
116
88
|
- !ruby/object:Gem::Version
|
117
|
-
segments:
|
118
|
-
- 0
|
119
|
-
- 0
|
120
|
-
- 8
|
121
89
|
version: 0.0.8
|
122
90
|
type: :development
|
123
91
|
prerelease: false
|
@@ -129,10 +97,6 @@ dependencies:
|
|
129
97
|
requirements:
|
130
98
|
- - ~>
|
131
99
|
- !ruby/object:Gem::Version
|
132
|
-
segments:
|
133
|
-
- 1
|
134
|
-
- 3
|
135
|
-
- 0
|
136
100
|
version: 1.3.0
|
137
101
|
type: :development
|
138
102
|
prerelease: false
|
@@ -144,10 +108,6 @@ dependencies:
|
|
144
108
|
requirements:
|
145
109
|
- - ~>
|
146
110
|
- !ruby/object:Gem::Version
|
147
|
-
segments:
|
148
|
-
- 1
|
149
|
-
- 3
|
150
|
-
- 4
|
151
111
|
version: 1.3.4
|
152
112
|
type: :development
|
153
113
|
prerelease: false
|
@@ -159,10 +119,6 @@ dependencies:
|
|
159
119
|
requirements:
|
160
120
|
- - ~>
|
161
121
|
- !ruby/object:Gem::Version
|
162
|
-
segments:
|
163
|
-
- 0
|
164
|
-
- 5
|
165
|
-
- 4
|
166
122
|
version: 0.5.4
|
167
123
|
type: :development
|
168
124
|
prerelease: false
|
@@ -174,10 +130,6 @@ dependencies:
|
|
174
130
|
requirements:
|
175
131
|
- - ~>
|
176
132
|
- !ruby/object:Gem::Version
|
177
|
-
segments:
|
178
|
-
- 1
|
179
|
-
- 4
|
180
|
-
- 3
|
181
133
|
version: 1.4.3
|
182
134
|
type: :development
|
183
135
|
prerelease: false
|
@@ -212,7 +164,9 @@ files:
|
|
212
164
|
- lib/omniauth/strategies/trip_it.rb
|
213
165
|
- lib/omniauth/strategies/twitter.rb
|
214
166
|
- lib/omniauth/strategies/type_pad.rb
|
167
|
+
- lib/omniauth/strategies/vimeo.rb
|
215
168
|
- lib/omniauth/strategies/yahoo.rb
|
169
|
+
- lib/omniauth/strategies/you_tube.rb
|
216
170
|
- README.rdoc
|
217
171
|
- LICENSE
|
218
172
|
has_rdoc: true
|
@@ -229,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
229
183
|
requirements:
|
230
184
|
- - ">="
|
231
185
|
- !ruby/object:Gem::Version
|
232
|
-
hash:
|
186
|
+
hash: 1607538061913859967
|
233
187
|
segments:
|
234
188
|
- 0
|
235
189
|
version: "0"
|
@@ -238,15 +192,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
192
|
requirements:
|
239
193
|
- - ">"
|
240
194
|
- !ruby/object:Gem::Version
|
241
|
-
segments:
|
242
|
-
- 1
|
243
|
-
- 3
|
244
|
-
- 1
|
245
195
|
version: 1.3.1
|
246
196
|
requirements: []
|
247
197
|
|
248
198
|
rubyforge_project:
|
249
|
-
rubygems_version: 1.
|
199
|
+
rubygems_version: 1.5.0
|
250
200
|
signing_key:
|
251
201
|
specification_version: 3
|
252
202
|
summary: OAuth strategies for OmniAuth.
|