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
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Glitch < OmniAuth::Strategies::OAuth2
|
7
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
8
|
+
|
9
|
+
# :scope (identity|read|write) is required for authorization and should be passed
|
10
|
+
# in the OmniAuth :provider options hash in your application
|
11
|
+
|
12
|
+
client_options = {
|
13
|
+
:site => 'http://api.glitch.com',
|
14
|
+
:authorize_url => '/oauth2/authorize',
|
15
|
+
:token_url => '/oauth2/token'
|
16
|
+
}
|
17
|
+
super(app, :glitch, client_id, client_secret, client_options, options, &block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def auth_hash
|
21
|
+
OmniAuth::Utils.deep_merge(
|
22
|
+
super, {
|
23
|
+
'uid' => user_data['player_tsid'],
|
24
|
+
'user_info' => user_info,
|
25
|
+
'extra' => user_data,
|
26
|
+
}
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def user_data
|
31
|
+
@access_token.options.merge!({:param_name => 'oauth_token', :mode => :query})
|
32
|
+
response = @access_token.post('/simple/players.info')
|
33
|
+
@data ||= MultiJson.decode(response.body)
|
34
|
+
end
|
35
|
+
|
36
|
+
def user_info
|
37
|
+
{
|
38
|
+
'name' => user_data['user_name'],
|
39
|
+
'nickname' => user_data['player_name'],
|
40
|
+
'image' => user_data['avatar_url'],
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
# Authenticate to Gowalla utilizing OAuth 2.0 and retrieve
|
7
|
+
# basic user information.
|
8
|
+
#
|
9
|
+
# @example Basic Usage
|
10
|
+
# use OmniAuth::Strategies::Gowalla, 'API Key', 'Secret Key'
|
11
|
+
class Gowalla < OmniAuth::Strategies::OAuth2
|
12
|
+
# @param [Rack Application] app standard middleware application parameter
|
13
|
+
# @param [String] client_id the application id as [registered on Gowalla](http://gowalla.com/api/keys)
|
14
|
+
# @param [String] client_secret the application secret as [registered on Gowalla](http://gowalla.com/api/keys)
|
15
|
+
# @option options ['read','read-write'] :scope ('read') the scope of your authorization request; must be `read` or `read-write`
|
16
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
17
|
+
client_options = {
|
18
|
+
:authorize_url => 'https://gowalla.com/api/oauth/new',
|
19
|
+
:token_url => 'https://api.gowalla.com/api/oauth/token',
|
20
|
+
}
|
21
|
+
super(app, :gowalla, client_id, client_secret, client_options, options, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def auth_hash
|
25
|
+
OmniAuth::Utils.deep_merge(
|
26
|
+
super, {
|
27
|
+
'uid' => user_data['url'].split('/').last,
|
28
|
+
'user_info' => user_info,
|
29
|
+
'extra' => {
|
30
|
+
'user_hash' => user_data,
|
31
|
+
'refresh_token' => refresh_token,
|
32
|
+
'token_expires_at' => token_expires_at,
|
33
|
+
},
|
34
|
+
}
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def user_data
|
39
|
+
@data ||= MultiJson.decode(@access_token.get('/users/me.json'))
|
40
|
+
end
|
41
|
+
|
42
|
+
def refresh_token
|
43
|
+
@refresh_token ||= @access_token.refresh_token
|
44
|
+
end
|
45
|
+
|
46
|
+
def token_expires_at
|
47
|
+
@expires_at ||= @access_token.expires_at
|
48
|
+
end
|
49
|
+
|
50
|
+
def request_phase
|
51
|
+
options[:scope] ||= 'read'
|
52
|
+
super
|
53
|
+
end
|
54
|
+
|
55
|
+
def user_info
|
56
|
+
{
|
57
|
+
'name' => "#{user_data['first_name']} #{user_data['last_name']}",
|
58
|
+
'nickname' => user_data['username'],
|
59
|
+
'first_name' => user_data['first_name'],
|
60
|
+
'last_name' => user_data['last_name'],
|
61
|
+
'location' => user_data['hometown'],
|
62
|
+
'description' => user_data['bio'],
|
63
|
+
'image' => user_data['image_url'],
|
64
|
+
'urls' => {
|
65
|
+
'Gowalla' => "http://www.gowalla.com#{user_data['url']}",
|
66
|
+
'Website' => user_data['website'],
|
67
|
+
},
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -8,20 +8,30 @@ module OmniAuth
|
|
8
8
|
#
|
9
9
|
# @example Basic Usage
|
10
10
|
# use OmniAuth::Strategies::Instagram, 'client_id', 'client_secret'
|
11
|
-
class Instagram < OAuth2
|
11
|
+
class Instagram < OmniAuth::Strategies::OAuth2
|
12
12
|
# @option options [String] :scope separate the scopes by a space
|
13
|
-
def initialize(app, client_id
|
13
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
14
14
|
client_options = {
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:access_token_url => "/oauth/access_token"
|
15
|
+
:authorize_url => 'https://api.instagram.com/oauth/authorize',
|
16
|
+
:token_url => 'https://api.instagram.com/oauth/access_token',
|
18
17
|
}
|
19
|
-
|
20
18
|
super(app, :instagram, client_id, client_secret, client_options, options, &block)
|
21
19
|
end
|
22
20
|
|
21
|
+
def auth_hash
|
22
|
+
OmniAuth::Utils.deep_merge(
|
23
|
+
super, {
|
24
|
+
'uid' => user_data['data']['id'],
|
25
|
+
'user_info' => user_info,
|
26
|
+
'extra' => {
|
27
|
+
'user_hash' => user_data['data'],
|
28
|
+
}
|
29
|
+
}
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
23
33
|
def request_phase
|
24
|
-
options[:scope] ||=
|
34
|
+
options[:scope] ||= 'basic'
|
25
35
|
options[:response_type] ||= 'code'
|
26
36
|
super
|
27
37
|
end
|
@@ -32,7 +42,8 @@ module OmniAuth
|
|
32
42
|
end
|
33
43
|
|
34
44
|
def user_data
|
35
|
-
@
|
45
|
+
@access_token.options.merge!({:param_name => 'access_token', :mode => :query})
|
46
|
+
@data ||= MultiJson.decode(@access_token.get('/v1/users/self'))
|
36
47
|
end
|
37
48
|
|
38
49
|
def user_info
|
@@ -40,17 +51,8 @@ module OmniAuth
|
|
40
51
|
'nickname' => user_data['data']['username'],
|
41
52
|
'name' => user_data['data']['full_name'],
|
42
53
|
'image' => user_data['data']['profile_picture'],
|
43
|
-
'urls' => {}
|
44
54
|
}
|
45
55
|
end
|
46
|
-
|
47
|
-
def auth_hash
|
48
|
-
OmniAuth::Utils.deep_merge(super, {
|
49
|
-
'uid' => user_data['data']['id'],
|
50
|
-
'user_info' => user_info,
|
51
|
-
'extra' => {'user_hash' => user_data['data']}
|
52
|
-
})
|
53
|
-
end
|
54
56
|
end
|
55
57
|
end
|
56
58
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
# Authenticate to Windows Connect utilizing OAuth 2.0 and retrieve
|
7
|
+
# basic user information.
|
8
|
+
#
|
9
|
+
# OAuth 2.0 - MS Documentation
|
10
|
+
# http://msdn.microsoft.com/en-us/library/hh243647.aspx
|
11
|
+
#
|
12
|
+
# Sign-up for account:
|
13
|
+
# http://go.microsoft.com/fwlink/?LinkId=213332
|
14
|
+
#
|
15
|
+
# @example Basic Usage of Liveid
|
16
|
+
#
|
17
|
+
# use OmniAuth::Strategies::Liveid, 'client_id', 'client_secret'
|
18
|
+
class Liveid < OmniAuth::Strategies::OAuth2
|
19
|
+
# @option options [String] :scope separate the scopes by a space
|
20
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
21
|
+
client_options = {
|
22
|
+
:authorize_url => 'https://oauth.live.com/authorize',
|
23
|
+
:token_url => 'https://oauth.live.com/token'
|
24
|
+
}
|
25
|
+
|
26
|
+
super(app, :liveid, client_id, client_secret, client_options, options, &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def auth_hash
|
30
|
+
OmniAuth::Utils.deep_merge(
|
31
|
+
super,
|
32
|
+
{
|
33
|
+
'uid' => user_data['id'],
|
34
|
+
'user_info' => user_info,
|
35
|
+
'extra' => {
|
36
|
+
'user_hash' => user_data,
|
37
|
+
}
|
38
|
+
}
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def request_phase
|
43
|
+
options[:scope] ||= 'wl.signin wl.basic'
|
44
|
+
options[:response_type] ||= 'code'
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
48
|
+
def user_data
|
49
|
+
@data ||= MultiJson.decode(@access_token.get('https://apis.live.net/v5.0/me').body)
|
50
|
+
end
|
51
|
+
|
52
|
+
def user_info
|
53
|
+
{
|
54
|
+
'id' => user_data['id'],
|
55
|
+
'name' => user_data['name'],
|
56
|
+
'email' => '',
|
57
|
+
'first_name' => user_data['first_name'],
|
58
|
+
'last_name' => user_data['last_name'],
|
59
|
+
'link' => user_data['link'],
|
60
|
+
'gender' => user_data['gender'],
|
61
|
+
'locale' => user_data['locale']
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Mailchimp < OmniAuth::Strategies::OAuth2
|
7
|
+
|
8
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
9
|
+
client_options = {
|
10
|
+
:authorize_url => 'https://login.mailchimp.com/oauth2/authorize',
|
11
|
+
:token_url => 'https://login.mailchimp.com/oauth2/token',
|
12
|
+
}
|
13
|
+
super(app, :mailchimp, client_id, client_secret, client_options, options, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
def auth_hash
|
17
|
+
data = user_data
|
18
|
+
OmniAuth::Utils.deep_merge(
|
19
|
+
super, {
|
20
|
+
'uid' => @access_token.client.id,
|
21
|
+
'extra'=> {
|
22
|
+
'user_hash' => data
|
23
|
+
}
|
24
|
+
}
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def user_data
|
29
|
+
@data ||= MultiJson.decode(@access_token.get("https://login.mailchimp.com/oauth2/metadata").body)
|
30
|
+
rescue ::OAuth2::Error => e
|
31
|
+
if e.response.status == 302
|
32
|
+
@data ||= MultiJson.decode(@access_token.get(e.response.headers['location']))
|
33
|
+
else
|
34
|
+
raise e
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
# Authenticate to Vkontakte utilizing OAuth 2.0 and retrieve
|
7
|
+
# basic user information.
|
8
|
+
# documentation available here:
|
9
|
+
# http://api.mail.ru/docs/guides/oauth/sites/
|
10
|
+
#
|
11
|
+
# @example Basic Usage
|
12
|
+
# use OmniAuth::Strategies::Mailru, 'API Key', 'Secret Key', :private_key => 'Private Key'
|
13
|
+
class Mailru < OmniAuth::Strategies::OAuth2
|
14
|
+
# @param [Rack Application] app standard middleware application parameter
|
15
|
+
# @param [String] client_id the application id as [registered in Mailru]
|
16
|
+
# @param [String] client_secret the application secret as [registered in Mailru]
|
17
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
18
|
+
client_options = {
|
19
|
+
:authorize_url => 'https://connect.mail.ru/oauth/authorize',
|
20
|
+
:token_url => 'https://connect.mail.ru/oauth/token',
|
21
|
+
}
|
22
|
+
@private_key = options[:private_key]
|
23
|
+
super(app, :mailru, client_id, client_secret, client_options, options, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
def auth_hash
|
27
|
+
OmniAuth::Utils.deep_merge(
|
28
|
+
super, {
|
29
|
+
'uid' => user_data['uid'],
|
30
|
+
'user_info' => user_info,
|
31
|
+
'extra' => {
|
32
|
+
'user_hash' => user_data,
|
33
|
+
},
|
34
|
+
}
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def request_phase
|
39
|
+
options[:response_type] ||= 'code'
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def calculate_signature(params)
|
44
|
+
str = params['uids'] + (params.sort.collect { |c| "#{c[0]}=#{c[1]}" }).join('') + @private_key
|
45
|
+
Digest::MD5.hexdigest(str)
|
46
|
+
end
|
47
|
+
|
48
|
+
def user_data
|
49
|
+
request_params = {
|
50
|
+
'method' => 'users.getInfo',
|
51
|
+
'app_id' => client_id,
|
52
|
+
'session_key' => @access_token.token,
|
53
|
+
'uids' => @access_token['x_mailru_vid']
|
54
|
+
}
|
55
|
+
|
56
|
+
request_params.merge!('sig' => calculate_signature(request_params))
|
57
|
+
@data ||= MultiJson.decode(client.request(:get, 'http://www.appsmail.ru/platform/api', request_params))[0]
|
58
|
+
end
|
59
|
+
|
60
|
+
def user_info
|
61
|
+
{
|
62
|
+
'nickname' => user_data['nick'],
|
63
|
+
'email' => user_data['email'],
|
64
|
+
'first_name' => user_data['first_name'],
|
65
|
+
'last_name' => user_data['last_name'],
|
66
|
+
'name' => "#{user_data['first_name']} #{user_data['last_name']}".strip,
|
67
|
+
'image' => @data['pic'],
|
68
|
+
'urls' => {
|
69
|
+
'Mailru' => user_data['link'],
|
70
|
+
},
|
71
|
+
}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -8,28 +8,39 @@ module OmniAuth
|
|
8
8
|
#
|
9
9
|
# @example Basic Usage
|
10
10
|
# use OmniAuth::Strategies::Mixi, 'client_id', 'client_secret'
|
11
|
-
class Mixi < OAuth2
|
11
|
+
class Mixi < OmniAuth::Strategies::OAuth2
|
12
12
|
# @option options [String] :scope separate the scopes by a space
|
13
|
-
def initialize(app, client_id
|
13
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
14
14
|
client_options = {
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:access_token_url => "https://secure.mixi-platform.com/2/token"
|
15
|
+
:authorize_url => 'https://mixi.jp/connect_authorize.pl',
|
16
|
+
:token_url => 'https://secure.mixi-platform.com/2/token',
|
18
17
|
}
|
19
|
-
|
20
18
|
super(app, :mixi, client_id, client_secret, client_options, options, &block)
|
21
19
|
end
|
22
20
|
|
21
|
+
def auth_hash
|
22
|
+
OmniAuth::Utils.deep_merge(
|
23
|
+
super, {
|
24
|
+
'uid' => user_data['entry']['id'],
|
25
|
+
'user_info' => user_info,
|
26
|
+
'credentials' => {'refresh_token' => @access_token.refresh_token},
|
27
|
+
'extra' => {
|
28
|
+
'user_hash' => user_data['entry'],
|
29
|
+
},
|
30
|
+
}
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
23
34
|
def user_data
|
24
35
|
@data ||= MultiJson.decode(@access_token.get(
|
25
|
-
|
36
|
+
'http://api.mixi-platform.com/2/people/@me/@self',
|
26
37
|
{'oauth_token' => @access_token.token}
|
27
38
|
))
|
28
39
|
end
|
29
40
|
|
30
41
|
def request_phase
|
31
|
-
options[:scope] ||=
|
32
|
-
options[:display] ||=
|
42
|
+
options[:scope] ||= 'r_profile'
|
43
|
+
options[:display] ||= 'pc'
|
33
44
|
options[:response_type] ||= 'code'
|
34
45
|
super
|
35
46
|
end
|
@@ -43,17 +54,11 @@ module OmniAuth
|
|
43
54
|
{
|
44
55
|
'nickname' => user_data['entry']['displayName'],
|
45
56
|
'image' => user_data['entry']['thumbnailUrl'],
|
46
|
-
'urls' => {
|
57
|
+
'urls' => {
|
58
|
+
:profile => user_data['entry']['profileUrl'],
|
59
|
+
},
|
47
60
|
}
|
48
61
|
end
|
49
|
-
|
50
|
-
def auth_hash
|
51
|
-
OmniAuth::Utils.deep_merge(super, {
|
52
|
-
'uid' => user_data['entry']['id'],
|
53
|
-
'user_info' => user_info,
|
54
|
-
'extra' => {'user_hash' => user_data['entry']}
|
55
|
-
})
|
56
|
-
end
|
57
62
|
end
|
58
63
|
end
|
59
64
|
end
|
@@ -10,21 +10,31 @@ module OmniAuth
|
|
10
10
|
#
|
11
11
|
# @example Basic Usage
|
12
12
|
# use OmniAuth::Strategies::Renren, 'client_id', 'client_secret'
|
13
|
-
class Renren < OAuth2
|
13
|
+
class Renren < OmniAuth::Strategies::OAuth2
|
14
14
|
# @param [Rack Application] app standard middleware application parameter
|
15
15
|
# @param [String] client_id the application id as [registered on Renren](http://dev.renren.com/)
|
16
16
|
# @param [String] client_secret the application secret as registered on Renren
|
17
17
|
# @option options [String] :scope ('publish_feed,status_update') comma-separated extended permissions such as `publish_feed` and `status_update`
|
18
|
-
def initialize(app, client_id
|
18
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
19
19
|
client_options = {
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:access_token_url => "/oauth/token"
|
20
|
+
:authorize_url => 'http://graph.renren.com/oauth/authorize',
|
21
|
+
:token_url => 'http://graph.renren.com/oauth/token',
|
23
22
|
}
|
24
|
-
|
25
23
|
super(app, :renren, client_id, client_secret, client_options, options, &block)
|
26
24
|
end
|
27
25
|
|
26
|
+
def auth_hash
|
27
|
+
OmniAuth::Utils.deep_merge(
|
28
|
+
super, {
|
29
|
+
'uid' => user_data['uid'],
|
30
|
+
'user_info' => user_info,
|
31
|
+
'extra' => {
|
32
|
+
'user_hash' => user_data,
|
33
|
+
},
|
34
|
+
}
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
28
38
|
def user_data
|
29
39
|
@data ||= MultiJson.decode(Net::HTTP.post_form(URI.parse('http://api.renren.com/restserver.do'), signed_params).body)[0]
|
30
40
|
end
|
@@ -32,13 +42,13 @@ module OmniAuth
|
|
32
42
|
def signed_params
|
33
43
|
params = {}
|
34
44
|
params[:api_key] = client.id
|
35
|
-
params[:method] =
|
45
|
+
params[:method] = 'users.getInfo'
|
36
46
|
params[:call_id] = Time.now.to_i
|
37
|
-
params[:format] =
|
38
|
-
params[:v] =
|
39
|
-
params[:uids] = session_key[
|
40
|
-
params[:session_key] = session_key[
|
41
|
-
params[:sig] = Digest::MD5.hexdigest(params.map
|
47
|
+
params[:format] = 'json'
|
48
|
+
params[:v] = '1.0'
|
49
|
+
params[:uids] = session_key['user']['id']
|
50
|
+
params[:session_key] = session_key['renren_token']['session_key']
|
51
|
+
params[:sig] = Digest::MD5.hexdigest(params.map{|k,v| "#{k}=#{v}"}.sort.join + client.secret)
|
42
52
|
params
|
43
53
|
end
|
44
54
|
|
@@ -47,7 +57,7 @@ module OmniAuth
|
|
47
57
|
end
|
48
58
|
|
49
59
|
def request_phase
|
50
|
-
options[:scope] ||=
|
60
|
+
options[:scope] ||= 'publish_feed'
|
51
61
|
super
|
52
62
|
end
|
53
63
|
|
@@ -70,18 +80,10 @@ module OmniAuth
|
|
70
80
|
|
71
81
|
def user_info
|
72
82
|
{
|
73
|
-
'name' => user_data[
|
74
|
-
'image' => user_data[
|
83
|
+
'name' => user_data['name'],
|
84
|
+
'image' => user_data['tinyurl'],
|
75
85
|
}
|
76
86
|
end
|
77
|
-
|
78
|
-
def auth_hash
|
79
|
-
OmniAuth::Utils.deep_merge(super, {
|
80
|
-
'uid' => user_data['uid'],
|
81
|
-
'user_info' => user_info,
|
82
|
-
'extra' => {'user_hash' => user_data}
|
83
|
-
})
|
84
|
-
end
|
85
87
|
end
|
86
88
|
end
|
87
89
|
end
|