oa-oauth 0.2.6 → 0.3.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/lib/omniauth/oauth.rb +65 -47
- data/lib/omniauth/strategies/google_oauth2.rb +59 -0
- data/lib/omniauth/strategies/oauth.rb +8 -2
- data/lib/omniauth/strategies/oauth/blogger.rb +58 -0
- data/lib/omniauth/strategies/{dopplr.rb → oauth/dopplr.rb} +19 -21
- data/lib/omniauth/strategies/{douban.rb → oauth/douban.rb} +18 -18
- data/lib/omniauth/strategies/oauth/dropbox.rb +40 -0
- data/lib/omniauth/strategies/{evernote.rb → oauth/evernote.rb} +11 -13
- data/lib/omniauth/strategies/oauth/flattr.rb +47 -0
- data/lib/omniauth/strategies/oauth/flickr.rb +39 -0
- data/lib/omniauth/strategies/{goodreads.rb → oauth/goodreads.rb} +9 -9
- data/lib/omniauth/strategies/{google.rb → oauth/google.rb} +19 -20
- data/lib/omniauth/strategies/oauth/google_health.rb +71 -0
- data/lib/omniauth/strategies/oauth/google_health_sandbox.rb +74 -0
- data/lib/omniauth/strategies/oauth/hyves.rb +69 -0
- data/lib/omniauth/strategies/{identica.rb → oauth/identica.rb} +20 -16
- data/lib/omniauth/strategies/{linked_in.rb → oauth/linked_in.rb} +14 -14
- data/lib/omniauth/strategies/{meetup.rb → oauth/meetup.rb} +18 -16
- data/lib/omniauth/strategies/{miso.rb → oauth/miso.rb} +14 -7
- data/lib/omniauth/strategies/{netflix.rb → oauth/netflix.rb} +16 -14
- data/lib/omniauth/strategies/oauth/orkut.rb +63 -0
- data/lib/omniauth/strategies/oauth/plurk.rb +57 -0
- data/lib/omniauth/strategies/{qzone.rb → oauth/qzone.rb} +15 -12
- data/lib/omniauth/strategies/oauth/rdio.rb +48 -0
- data/lib/omniauth/strategies/oauth/smug_mug.rb +47 -0
- data/lib/omniauth/strategies/{t163.rb → oauth/t163.rb} +17 -17
- data/lib/omniauth/strategies/oauth/tqq.rb +63 -0
- data/lib/omniauth/strategies/oauth/trade_me.rb +50 -0
- data/lib/omniauth/strategies/oauth/trip_it.rb +24 -0
- data/lib/omniauth/strategies/{tsina.rb → oauth/tsina.rb} +21 -15
- data/lib/omniauth/strategies/{tsohu.rb → oauth/tsohu.rb} +15 -17
- data/lib/omniauth/strategies/{tumblr.rb → oauth/tumblr.rb} +13 -15
- data/lib/omniauth/strategies/{twitter.rb → oauth/twitter.rb} +17 -16
- data/lib/omniauth/strategies/{type_pad.rb → oauth/type_pad.rb} +18 -27
- data/lib/omniauth/strategies/{vimeo.rb → oauth/vimeo.rb} +18 -14
- data/lib/omniauth/strategies/{yahoo.rb → oauth/yahoo.rb} +17 -12
- data/lib/omniauth/strategies/{yammer.rb → oauth/yammer.rb} +17 -12
- data/lib/omniauth/strategies/{you_tube.rb → oauth/you_tube.rb} +16 -14
- data/lib/omniauth/strategies/oauth2.rb +7 -5
- data/lib/omniauth/strategies/oauth2/angellist.rb +57 -0
- data/lib/omniauth/strategies/oauth2/bitly.rb +43 -0
- data/lib/omniauth/strategies/oauth2/cobot.rb +54 -0
- data/lib/omniauth/strategies/{dailymile.rb → oauth2/dailymile.rb} +19 -20
- data/lib/omniauth/strategies/{doit.rb → oauth2/doit.rb} +18 -18
- data/lib/omniauth/strategies/{facebook.rb → oauth2/facebook.rb} +38 -21
- data/lib/omniauth/strategies/{foursquare.rb → oauth2/foursquare.rb} +20 -19
- data/lib/omniauth/strategies/{github.rb → oauth2/github.rb} +21 -19
- data/lib/omniauth/strategies/oauth2/glitch.rb +45 -0
- data/lib/omniauth/strategies/oauth2/gowalla.rb +72 -0
- data/lib/omniauth/strategies/{instagram.rb → oauth2/instagram.rb} +19 -17
- data/lib/omniauth/strategies/oauth2/liveid.rb +67 -0
- data/lib/omniauth/strategies/oauth2/mailchimp.rb +39 -0
- data/lib/omniauth/strategies/oauth2/mailru.rb +75 -0
- data/lib/omniauth/strategies/{mixi.rb → oauth2/mixi.rb} +23 -18
- data/lib/omniauth/strategies/{renren.rb → oauth2/renren.rb} +25 -23
- data/lib/omniauth/strategies/oauth2/salesforce.rb +48 -0
- data/lib/omniauth/strategies/oauth2/sound_cloud.rb +60 -0
- data/lib/omniauth/strategies/{taobao.rb → oauth2/taobao.rb} +24 -22
- data/lib/omniauth/strategies/{teambox.rb → oauth2/teambox.rb} +19 -17
- data/lib/omniauth/strategies/{thirty_seven_signals.rb → oauth2/thirty_seven_signals.rb} +17 -17
- data/lib/omniauth/strategies/oauth2/viadeo.rb +72 -0
- data/lib/omniauth/strategies/oauth2/vkontakte.rb +104 -0
- data/lib/omniauth/strategies/oauth2/we_pay.rb +48 -0
- data/lib/omniauth/strategies/xauth.rb +3 -3
- data/lib/omniauth/strategies/{instapaper.rb → xauth/instapaper.rb} +9 -12
- data/lib/omniauth/version.rb +3 -3
- data/oa-oauth.gemspec +17 -18
- data/spec/omniauth/strategies/{bitly_spec.rb → google_oauth2_spec.rb} +1 -1
- data/spec/omniauth/strategies/{dopplr_spec.rb → oauth/dopplr_spec.rb} +1 -1
- data/spec/omniauth/strategies/{douban_spec.rb → oauth/douban_spec.rb} +1 -1
- data/spec/omniauth/strategies/oauth/dropbox_spec.rb +5 -0
- data/spec/omniauth/strategies/{evernote_spec.rb → oauth/evernote_spec.rb} +1 -1
- data/spec/omniauth/strategies/oauth/flattr_spec.rb +5 -0
- data/spec/omniauth/strategies/oauth/flickr_spec.rb +6 -0
- data/spec/omniauth/strategies/{goodreads_spec.rb → oauth/goodreads_spec.rb} +1 -1
- data/spec/omniauth/strategies/oauth/google_health_sandbox_spec.rb +5 -0
- data/spec/omniauth/strategies/oauth/google_health_spec.rb +5 -0
- data/spec/omniauth/strategies/{google_spec.rb → oauth/google_spec.rb} +1 -1
- data/spec/omniauth/strategies/{hyves_spec.rb → oauth/hyves_spec.rb} +1 -1
- data/spec/omniauth/strategies/{identica_spec.rb → oauth/identica_spec.rb} +1 -1
- data/spec/omniauth/strategies/{linked_in_spec.rb → oauth/linked_in_spec.rb} +1 -1
- data/spec/omniauth/strategies/{meetup_spec.rb → oauth/meetup_spec.rb} +3 -3
- data/spec/omniauth/strategies/{miso_spec.rb → oauth/miso_spec.rb} +1 -1
- data/spec/omniauth/strategies/{netflix_spec.rb → oauth/netflix_spec.rb} +1 -1
- data/spec/omniauth/strategies/oauth/oauth_spec.rb +131 -0
- data/spec/omniauth/strategies/oauth/orkut_spec.rb +5 -0
- data/spec/omniauth/strategies/{plurk_spec.rb → oauth/plurk_spec.rb} +1 -1
- data/spec/omniauth/strategies/{rdio_spec.rb → oauth/rdio_spec.rb} +1 -1
- data/spec/omniauth/strategies/{smug_mug_spec.rb → oauth/smug_mug_spec.rb} +1 -1
- data/spec/omniauth/strategies/{t163_spec.rb → oauth/t163_spec.rb} +1 -1
- data/spec/omniauth/strategies/{trade_me_spec.rb → oauth/trade_me_spec.rb} +1 -1
- data/spec/omniauth/strategies/{trip_it_spec.rb → oauth/trip_it_spec.rb} +1 -1
- data/spec/omniauth/strategies/{tsina_spec.rb → oauth/tsina_spec.rb} +1 -1
- data/spec/omniauth/strategies/{tumblr_spec.rb → oauth/tumblr_spec.rb} +1 -1
- data/spec/omniauth/strategies/oauth/twitter_spec.rb +43 -0
- data/spec/omniauth/strategies/{type_pad_spec.rb → oauth/type_pad_spec.rb} +1 -1
- data/spec/omniauth/strategies/{vimeo_spec.rb → oauth/vimeo_spec.rb} +1 -1
- data/spec/omniauth/strategies/{yahoo_spec.rb → oauth/yahoo_spec.rb} +1 -1
- data/spec/omniauth/strategies/{yammer_spec.rb → oauth/yammer_spec.rb} +1 -1
- data/spec/omniauth/strategies/{you_tube_spec.rb → oauth/you_tube_spec.rb} +1 -1
- data/spec/omniauth/strategies/oauth2/angellist_spec.rb +5 -0
- data/spec/omniauth/strategies/oauth2/bitly_spec.rb +5 -0
- data/spec/omniauth/strategies/oauth2/cobot_spec.rb +5 -0
- data/spec/omniauth/strategies/{dailymile_spec.rb → oauth2/dailymile_spec.rb} +1 -1
- data/spec/omniauth/strategies/{doit_spec.rb → oauth2/doit_spec.rb} +1 -1
- data/spec/omniauth/strategies/{facebook_spec.rb → oauth2/facebook_spec.rb} +1 -1
- data/spec/omniauth/strategies/{foursquare_spec.rb → oauth2/foursquare_spec.rb} +1 -1
- data/spec/omniauth/strategies/{github_spec.rb → oauth2/github_spec.rb} +1 -1
- data/spec/omniauth/strategies/oauth2/glitch_spec.rb +5 -0
- data/spec/omniauth/strategies/{gowalla_spec.rb → oauth2/gowalla_spec.rb} +1 -1
- data/spec/omniauth/strategies/oauth2/instagram_spec.rb +5 -0
- data/spec/omniauth/strategies/oauth2/liveid_spec.rb +5 -0
- data/spec/omniauth/strategies/oauth2/mailchimp_spec.rb +6 -0
- data/spec/omniauth/strategies/{mailru_spec.rb → oauth2/mailru_spec.rb} +1 -1
- data/spec/omniauth/strategies/{salesforce_spec.rb → oauth2/salesforce_spec.rb} +1 -1
- data/spec/omniauth/strategies/oauth2/sound_cloud_spec.rb +5 -0
- data/spec/omniauth/strategies/oauth2/taobao_spec.rb +5 -0
- data/spec/omniauth/strategies/{teambox_spec.rb → oauth2/teambox_spec.rb} +1 -1
- data/spec/omniauth/strategies/{thirty_seven_signals_spec.rb → oauth2/thirty_seven_signals_spec.rb} +1 -1
- data/spec/omniauth/strategies/oauth2/viadeo_spec.rb +5 -0
- data/spec/omniauth/strategies/{vkontakte_spec.rb → oauth2/vkontakte_spec.rb} +1 -1
- data/spec/omniauth/strategies/oauth2/we_pay_spec.rb +5 -0
- data/spec/spec_helper.rb +4 -0
- metadata +277 -151
- data/lib/omniauth/strategies/bitly.rb +0 -46
- data/lib/omniauth/strategies/gowalla.rb +0 -72
- data/lib/omniauth/strategies/hyves.rb +0 -67
- data/lib/omniauth/strategies/mailru.rb +0 -107
- data/lib/omniauth/strategies/plurk.rb +0 -58
- data/lib/omniauth/strategies/rdio.rb +0 -45
- data/lib/omniauth/strategies/salesforce.rb +0 -44
- data/lib/omniauth/strategies/smug_mug.rb +0 -42
- data/lib/omniauth/strategies/sound_cloud.rb +0 -46
- data/lib/omniauth/strategies/tqq.rb +0 -64
- data/lib/omniauth/strategies/trade_me.rb +0 -45
- data/lib/omniauth/strategies/trip_it.rb +0 -22
- data/lib/omniauth/strategies/vkontakte.rb +0 -87
- data/spec/omniauth/strategies/oauth2_spec.rb +0 -0
- data/spec/omniauth/strategies/oauth_spec.rb +0 -77
- data/spec/omniauth/strategies/sound_cloud_spec.rb +0 -5
- data/spec/omniauth/strategies/taobao_spec.rb +0 -5
- data/spec/omniauth/strategies/twitter_spec.rb +0 -20
@@ -3,39 +3,38 @@ require 'multi_json'
|
|
3
3
|
|
4
4
|
module OmniAuth
|
5
5
|
module Strategies
|
6
|
-
#
|
7
6
|
# Authenticate to Twitter via OAuth and retrieve basic
|
8
7
|
# user information.
|
9
8
|
#
|
10
9
|
# Usage:
|
11
|
-
#
|
12
10
|
# use OmniAuth::Strategies::Twitter, 'consumerkey', 'consumersecret'
|
13
|
-
#
|
14
11
|
class Twitter < OmniAuth::Strategies::OAuth
|
15
12
|
# Initialize the middleware
|
16
13
|
#
|
17
14
|
# @option options [Boolean, true] :sign_in When true, use the "Sign in with Twitter" flow instead of the authorization flow.
|
18
|
-
def initialize(app, consumer_key
|
15
|
+
def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
|
19
16
|
client_options = {
|
20
|
-
:site => 'https://api.twitter.com'
|
17
|
+
:site => 'https://api.twitter.com',
|
21
18
|
}
|
22
|
-
|
23
19
|
options[:authorize_params] = {:force_login => 'true'} if options.delete(:force_login) == true
|
24
|
-
client_options[:authorize_path] = '/oauth/
|
25
|
-
super(app, :twitter, consumer_key, consumer_secret, client_options, options)
|
20
|
+
client_options[:authorize_path] = '/oauth/authorize' unless options[:sign_in] == false
|
21
|
+
super(app, options[:name] || :twitter, consumer_key, consumer_secret, client_options, options, &block)
|
26
22
|
end
|
27
23
|
|
28
24
|
def auth_hash
|
29
|
-
OmniAuth::Utils.deep_merge(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
OmniAuth::Utils.deep_merge(
|
26
|
+
super, {
|
27
|
+
'uid' => @access_token.params[:user_id],
|
28
|
+
'user_info' => user_info,
|
29
|
+
'extra' => {
|
30
|
+
'user_hash' => user_hash,
|
31
|
+
},
|
32
|
+
}
|
33
|
+
)
|
34
34
|
end
|
35
35
|
|
36
36
|
def user_info
|
37
37
|
user_hash = self.user_hash
|
38
|
-
|
39
38
|
{
|
40
39
|
'nickname' => user_hash['screen_name'],
|
41
40
|
'name' => user_hash['name'] || user_hash['screen_name'],
|
@@ -44,13 +43,15 @@ module OmniAuth
|
|
44
43
|
'description' => user_hash['description'],
|
45
44
|
'urls' => {
|
46
45
|
'Website' => user_hash['url'],
|
47
|
-
'Twitter' => 'http://twitter.com/' + user_hash['screen_name']
|
48
|
-
}
|
46
|
+
'Twitter' => 'http://twitter.com/' + user_hash['screen_name'],
|
47
|
+
},
|
49
48
|
}
|
50
49
|
end
|
51
50
|
|
52
51
|
def user_hash
|
53
52
|
@user_hash ||= MultiJson.decode(@access_token.get('/1/account/verify_credentials.json').body)
|
53
|
+
rescue ::Errno::ETIMEDOUT
|
54
|
+
raise ::Timeout::Error
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
@@ -3,56 +3,53 @@ require 'multi_json'
|
|
3
3
|
|
4
4
|
module OmniAuth
|
5
5
|
module Strategies
|
6
|
-
#
|
7
6
|
# Authenticate to Typepad via OAuth and retrieve basic
|
8
7
|
# user information.
|
9
8
|
#
|
10
9
|
# Usage:
|
11
|
-
#
|
12
10
|
# use OmniAuth::Strategies::Typepad, 'consumerkey', 'consumersecret', :application_id => 'my_type_pad_application_id'
|
13
|
-
#
|
14
11
|
# application_id is required.
|
15
|
-
#
|
16
12
|
class TypePad < OmniAuth::Strategies::OAuth
|
17
|
-
def initialize(app, consumer_key
|
18
|
-
|
13
|
+
def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
|
19
14
|
# TypePad uses the application ID for one of the OAuth paths.
|
20
15
|
app_id = options[:application_id]
|
21
|
-
|
22
16
|
client_options = {
|
23
|
-
:site => 'https://www.typepad.com',
|
24
|
-
:request_token_path => '/secure/services/oauth/request_token',
|
25
17
|
:access_token_path => '/secure/services/oauth/access_token',
|
26
18
|
:authorize_path => "/secure/services/api/#{app_id}/oauth-approve",
|
27
19
|
:http_method => :get,
|
28
20
|
# You *must* use query_string for the token dance.
|
29
|
-
:scheme => :query_string
|
21
|
+
:scheme => :query_string,
|
22
|
+
:site => 'https://www.typepad.com',
|
23
|
+
:request_token_path => '/secure/services/oauth/request_token',
|
30
24
|
}
|
31
|
-
|
32
25
|
options.merge! :scheme => :query_string, :http_method => :get
|
33
|
-
|
34
|
-
super(app, :type_pad, consumer_key, consumer_secret, client_options, options)
|
26
|
+
super(app, :type_pad, consumer_key, consumer_secret, client_options, options, &block)
|
35
27
|
end
|
36
28
|
|
37
29
|
def auth_hash
|
38
30
|
ui = user_info
|
39
|
-
OmniAuth::Utils.deep_merge(
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
31
|
+
OmniAuth::Utils.deep_merge(
|
32
|
+
super, {
|
33
|
+
'uid' => ui['uid'],
|
34
|
+
'user_info' => ui,
|
35
|
+
'extra' => {
|
36
|
+
'user_hash' => user_hash,
|
37
|
+
},
|
38
|
+
}
|
39
|
+
)
|
44
40
|
end
|
45
41
|
|
46
42
|
def user_info
|
47
43
|
user_hash = self.user_hash
|
48
|
-
|
49
44
|
{
|
50
45
|
'uid' => user_hash['urlId'],
|
51
46
|
'nickname' => user_hash['preferredUsername'],
|
52
47
|
'name' => user_hash['displayName'],
|
53
48
|
'image' => user_hash['avatarLink']['url'],
|
54
49
|
'description' => user_hash['aboutMe'],
|
55
|
-
'urls' => {
|
50
|
+
'urls' => {
|
51
|
+
'Profile' => user_hash['profilePageUrl'],
|
52
|
+
},
|
56
53
|
}
|
57
54
|
end
|
58
55
|
|
@@ -62,13 +59,7 @@ module OmniAuth
|
|
62
59
|
# 'Unauthorized' is the response body of a truly unauthorized request.
|
63
60
|
|
64
61
|
# Also note that API requests hit a different site than the OAuth dance.
|
65
|
-
r = self.consumer.request(
|
66
|
-
:get,
|
67
|
-
"https://api.typepad.com/users/@self.json",
|
68
|
-
@access_token,
|
69
|
-
:scheme => 'header'
|
70
|
-
)
|
71
|
-
|
62
|
+
r = self.consumer.request(:get, 'https://api.typepad.com/users/@self.json', @access_token, :scheme => 'header')
|
72
63
|
@user_hash ||= MultiJson.decode(r.body)
|
73
64
|
end
|
74
65
|
end
|
@@ -11,23 +11,27 @@ module OmniAuth
|
|
11
11
|
# use OmniAuth::Strategies::Vimeo, 'consumerkey', 'consumersecret'
|
12
12
|
#
|
13
13
|
class Vimeo < OmniAuth::Strategies::OAuth
|
14
|
-
def initialize(app, consumer_key
|
15
|
-
|
16
|
-
:
|
14
|
+
def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
|
15
|
+
client_options = {
|
16
|
+
:access_token_path => '/oauth/access_token',
|
17
|
+
:authorize_path => '/oauth/authorize',
|
17
18
|
:request_token_path => '/oauth/request_token',
|
18
|
-
:
|
19
|
-
:authorize_path => '/oauth/authorize'
|
19
|
+
:site => 'http://vimeo.com',
|
20
20
|
}
|
21
|
-
super(app, :vimeo, consumer_key, consumer_secret,
|
21
|
+
super(app, :vimeo, consumer_key, consumer_secret, client_options, options, &block)
|
22
22
|
end
|
23
23
|
|
24
24
|
def auth_hash
|
25
25
|
user = user_hash['person']
|
26
|
-
OmniAuth::Utils.deep_merge(
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
OmniAuth::Utils.deep_merge(
|
27
|
+
super, {
|
28
|
+
'uid' => user['id'],
|
29
|
+
'user_info' => user_info,
|
30
|
+
'extra' => {
|
31
|
+
'user_hash' => user,
|
32
|
+
},
|
33
|
+
}
|
34
|
+
)
|
31
35
|
end
|
32
36
|
|
33
37
|
def user_info
|
@@ -40,13 +44,13 @@ module OmniAuth
|
|
40
44
|
'image' => user['portraits']['portrait'].select{|h| h['height'] == '300'}.first['_content'],
|
41
45
|
'urls' => {
|
42
46
|
'website' => user['url'],
|
43
|
-
'vimeo' => user['profileurl']
|
44
|
-
}
|
47
|
+
'vimeo' => user['profileurl'],
|
48
|
+
},
|
45
49
|
}
|
46
50
|
end
|
47
51
|
|
48
52
|
def user_hash
|
49
|
-
url =
|
53
|
+
url = 'http://vimeo.com/api/rest/v2?method=vimeo.people.getInfo&format=json'
|
50
54
|
@user_hash ||= MultiJson.decode(@access_token.get(url).body)
|
51
55
|
end
|
52
56
|
end
|
@@ -12,24 +12,27 @@ module OmniAuth
|
|
12
12
|
# use OmniAuth::Strategies::Yahoo, 'consumerkey', 'consumersecret'
|
13
13
|
#
|
14
14
|
class Yahoo < OmniAuth::Strategies::OAuth
|
15
|
-
def initialize(app, consumer_key
|
15
|
+
def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
|
16
16
|
client_options = {
|
17
|
-
:site => 'https://api.login.yahoo.com',
|
18
|
-
:request_token_path => '/oauth/v2/get_request_token',
|
19
17
|
:access_token_path => '/oauth/v2/get_token',
|
20
|
-
:authorize_path =>
|
18
|
+
:authorize_path => '/oauth/v2/request_auth',
|
19
|
+
:request_token_path => '/oauth/v2/get_request_token',
|
20
|
+
:site => 'https://api.login.yahoo.com',
|
21
21
|
}
|
22
|
-
|
23
|
-
super(app, :yahoo, consumer_key, consumer_secret, client_options, options)
|
22
|
+
super(app, :yahoo, consumer_key, consumer_secret, client_options, options, &block)
|
24
23
|
end
|
25
24
|
|
26
25
|
def auth_hash
|
27
26
|
ui = user_info
|
28
|
-
OmniAuth::Utils.deep_merge(
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
OmniAuth::Utils.deep_merge(
|
28
|
+
super, {
|
29
|
+
'uid' => ui['uid'],
|
30
|
+
'user_info' => ui,
|
31
|
+
'extra' => {
|
32
|
+
'user_hash' => user_hash,
|
33
|
+
},
|
34
|
+
}
|
35
|
+
)
|
33
36
|
end
|
34
37
|
|
35
38
|
def user_info
|
@@ -42,7 +45,9 @@ module OmniAuth
|
|
42
45
|
'name' => profile['givenName'] || nickname,
|
43
46
|
'image' => profile['image']['imageUrl'],
|
44
47
|
'description' => profile['message'],
|
45
|
-
'urls' => {
|
48
|
+
'urls' => {
|
49
|
+
'Profile' => profile['profileUrl'],
|
50
|
+
},
|
46
51
|
}
|
47
52
|
end
|
48
53
|
|
@@ -4,23 +4,26 @@ require 'multi_json'
|
|
4
4
|
module OmniAuth
|
5
5
|
module Strategies
|
6
6
|
class Yammer < OmniAuth::Strategies::OAuth
|
7
|
-
def initialize(app, consumer_key
|
7
|
+
def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
|
8
8
|
client_options = {
|
9
|
-
:site => 'https://www.yammer.com',
|
10
|
-
:request_token_path => '/oauth/request_token',
|
11
9
|
:access_token_path => '/oauth/access_token',
|
12
|
-
:authorize_path =>
|
10
|
+
:authorize_path => '/oauth/authorize',
|
11
|
+
:request_token_path => '/oauth/request_token',
|
12
|
+
:site => 'https://www.yammer.com',
|
13
13
|
}
|
14
|
-
|
15
|
-
super(app, :yammer, consumer_key, consumer_secret, client_options, options)
|
14
|
+
super(app, :yammer, consumer_key, consumer_secret, client_options, options, &block)
|
16
15
|
end
|
17
16
|
|
18
17
|
def auth_hash
|
19
|
-
OmniAuth::Utils.deep_merge(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
OmniAuth::Utils.deep_merge(
|
19
|
+
super, {
|
20
|
+
'uid' => user_hash['id'],
|
21
|
+
'user_info' => user_info,
|
22
|
+
'extra' => {
|
23
|
+
'user_hash' => user_hash,
|
24
|
+
},
|
25
|
+
}
|
26
|
+
)
|
24
27
|
end
|
25
28
|
|
26
29
|
def user_info
|
@@ -31,7 +34,9 @@ module OmniAuth
|
|
31
34
|
'location' => user_hash['location'],
|
32
35
|
'image' => user_hash['mugshot-url'],
|
33
36
|
'description' => user_hash['job-title'],
|
34
|
-
'urls' => {
|
37
|
+
'urls' => {
|
38
|
+
'Yammer' => user_hash['web-url'],
|
39
|
+
},
|
35
40
|
}
|
36
41
|
end
|
37
42
|
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# Based heavily on the Google strategy, monkeypatch and all
|
2
|
-
|
3
2
|
require 'omniauth/oauth'
|
4
3
|
require 'multi_json'
|
5
4
|
|
@@ -13,24 +12,27 @@ module OmniAuth
|
|
13
12
|
# use OmniAuth::Strategies::YouTube, 'consumerkey', 'consumersecret'
|
14
13
|
#
|
15
14
|
class YouTube < OmniAuth::Strategies::OAuth
|
16
|
-
def initialize(app, consumer_key
|
15
|
+
def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
|
17
16
|
client_options = {
|
18
|
-
:site => 'https://www.google.com',
|
19
|
-
:request_token_path => '/accounts/OAuthGetRequestToken',
|
20
17
|
:access_token_path => '/accounts/OAuthGetAccessToken',
|
21
|
-
:authorize_path => '/accounts/OAuthAuthorizeToken'
|
18
|
+
:authorize_path => '/accounts/OAuthAuthorizeToken',
|
19
|
+
:request_token_path => '/accounts/OAuthGetRequestToken',
|
20
|
+
:site => 'https://www.google.com',
|
22
21
|
}
|
23
|
-
|
24
|
-
super(app, :you_tube, consumer_key, consumer_secret, client_options, options)
|
22
|
+
super(app, :you_tube, consumer_key, consumer_secret, client_options, options, &block)
|
25
23
|
end
|
26
24
|
|
27
25
|
def auth_hash
|
28
26
|
ui = user_info
|
29
|
-
OmniAuth::Utils.deep_merge(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
OmniAuth::Utils.deep_merge(
|
28
|
+
super, {
|
29
|
+
'uid' => ui['uid'],
|
30
|
+
'user_info' => ui,
|
31
|
+
'extra' => {
|
32
|
+
'user_hash' => user_hash,
|
33
|
+
},
|
34
|
+
}
|
35
|
+
)
|
34
36
|
end
|
35
37
|
|
36
38
|
def user_info
|
@@ -42,14 +44,14 @@ module OmniAuth
|
|
42
44
|
'last_name' => entry['yt$lastName'] && entry['yt$lastName']['$t'],
|
43
45
|
'image' => entry['media$thumbnail'] && entry['media$thumbnail']['url'],
|
44
46
|
'description' => entry['yt$description'] && entry['yt$description']['$t'],
|
45
|
-
'location' => entry['yt$location'] && entry['yt$location']['$t']
|
47
|
+
'location' => entry['yt$location'] && entry['yt$location']['$t'],
|
46
48
|
}
|
47
49
|
end
|
48
50
|
|
49
51
|
def user_hash
|
50
52
|
# YouTube treats 'default' as the currently logged-in user
|
51
53
|
# via http://apiblog.youtube.com/2010/11/update-to-clientlogin-url.html
|
52
|
-
@user_hash ||= MultiJson.decode(@access_token.get(
|
54
|
+
@user_hash ||= MultiJson.decode(@access_token.get('http://gdata.youtube.com/feeds/api/users/default?alt=json').body)
|
53
55
|
end
|
54
56
|
|
55
57
|
# Monkeypatch consumer.get_request_token but specify YouTube scope rather than Google Contacts
|
@@ -37,7 +37,7 @@ module OmniAuth
|
|
37
37
|
# @param [String] client_id the client/application ID of this provider
|
38
38
|
# @param [String] client_secret the client/application secret of this provider
|
39
39
|
# @param [Hash] options that will be passed through to the OAuth2::Client (see [oauth2 docs](http://rubydoc.info/gems/oauth2))
|
40
|
-
def initialize(app, name, client_id
|
40
|
+
def initialize(app, name, client_id=nil, client_secret=nil, client_options={}, options={}, &block)
|
41
41
|
self.client_id = client_id
|
42
42
|
self.client_secret = client_secret
|
43
43
|
self.client_options = client_options
|
@@ -55,7 +55,7 @@ module OmniAuth
|
|
55
55
|
protected
|
56
56
|
|
57
57
|
def request_phase
|
58
|
-
redirect client.
|
58
|
+
redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(options))
|
59
59
|
end
|
60
60
|
|
61
61
|
def callback_phase
|
@@ -64,10 +64,10 @@ module OmniAuth
|
|
64
64
|
end
|
65
65
|
|
66
66
|
@access_token = build_access_token
|
67
|
-
@access_token = client.
|
67
|
+
@access_token = client.auth_code.refresh_token(@access_token.refresh_token) if @access_token.expired?
|
68
68
|
|
69
69
|
super
|
70
|
-
rescue ::OAuth2::
|
70
|
+
rescue ::OAuth2::Error, CallbackError => e
|
71
71
|
fail!(:invalid_credentials, e)
|
72
72
|
rescue ::MultiJson::DecodeError => e
|
73
73
|
fail!(:invalid_response, e)
|
@@ -77,7 +77,9 @@ module OmniAuth
|
|
77
77
|
|
78
78
|
def build_access_token
|
79
79
|
verifier = request.params['code']
|
80
|
-
client.
|
80
|
+
client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(options))
|
81
|
+
rescue ::OAuth2::Error => e
|
82
|
+
raise e.response.inspect
|
81
83
|
end
|
82
84
|
|
83
85
|
def auth_hash
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
# Authenticate to AngelList utilizing OAuth 2.0 and retrieve
|
7
|
+
# basic user information.
|
8
|
+
#
|
9
|
+
# @example Basic Usage
|
10
|
+
# use OmniAuth::Strategies::AngelList, 'API Key', 'Secret Key'
|
11
|
+
class AngelList < OmniAuth::Strategies::OAuth2
|
12
|
+
# @param [Rack Application] app standard middleware application parameter
|
13
|
+
# @param [String] client_id the application id as [registered on AngelList](http://angel.co/api/oauth/faq)
|
14
|
+
# @param [String] client_secret the application secret as [registered on AngelList](http://bit.ly/api/oauth/faq )
|
15
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
16
|
+
client_options = {
|
17
|
+
:site => 'https://api.angel.co/',
|
18
|
+
:authorize_url => 'https://angel.co/api/oauth/authorize',
|
19
|
+
:token_url => 'https://angel.co/api/oauth/token'
|
20
|
+
}
|
21
|
+
|
22
|
+
super(app, :angellist, client_id, client_secret, client_options, options, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def auth_hash
|
26
|
+
OmniAuth::Utils.deep_merge(
|
27
|
+
super, {
|
28
|
+
'uid' => user_data['id'],
|
29
|
+
'user_info' => user_info,
|
30
|
+
'extra' => {
|
31
|
+
'user_hash' => user_data,
|
32
|
+
}
|
33
|
+
}
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def user_info
|
38
|
+
{
|
39
|
+
'name' => user_data['name'],
|
40
|
+
'bio' => user_data['bio'],
|
41
|
+
'image' => user_data['image'],
|
42
|
+
'urls' => {
|
43
|
+
'AngelList' => user_data['angellist_url'],
|
44
|
+
'Website' => user_data['online_bio_url']
|
45
|
+
},
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def user_data
|
50
|
+
@data ||= begin
|
51
|
+
@access_token.options[:mode] = :query
|
52
|
+
@access_token.get('/1/me').parsed
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|