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,43 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
# Authenticate to Bitly utilizing OAuth 2.0 and retrieve
|
7
|
+
# basic user information.
|
8
|
+
#
|
9
|
+
# @example Basic Usage
|
10
|
+
# use OmniAuth::Strategies::Bitly, 'API Key', 'Secret Key'
|
11
|
+
class Bitly < OmniAuth::Strategies::OAuth2
|
12
|
+
# @param [Rack Application] app standard middleware application parameter
|
13
|
+
# @param [String] client_id the application id as [registered on Bitly](http://bit.ly/a/account)
|
14
|
+
# @param [String] client_secret the application secret as [registered on Bitly](http://bit.ly/a/account)
|
15
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
16
|
+
client_options = {
|
17
|
+
:authorize_url => 'https://bit.ly/oauth/authorize',
|
18
|
+
:token_url => 'https://api-ssl.bit.ly/oauth/access_token',
|
19
|
+
}
|
20
|
+
super(app, :bitly, client_id, client_secret, client_options, options, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def auth_hash
|
24
|
+
OmniAuth::Utils.deep_merge(
|
25
|
+
super, {
|
26
|
+
'uid' => @access_token['login'],
|
27
|
+
'user_info' => user_data,
|
28
|
+
'extra' => {
|
29
|
+
'user_hash' => user_data,
|
30
|
+
},
|
31
|
+
}
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def user_data
|
36
|
+
{
|
37
|
+
'login' => @access_token['login'],
|
38
|
+
'client_id' => @access_token['apiKey'],
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
# Authenticate to Cobot utilizing OAuth 2.0 and retrieve
|
7
|
+
# basic user information.
|
8
|
+
#
|
9
|
+
# @example Basic Usage
|
10
|
+
# use OmniAuth::Strategies::Cobot, 'Client ID', 'Client Secret'
|
11
|
+
class Cobot < OmniAuth::Strategies::OAuth2
|
12
|
+
# @param [Rack Application] app standard middleware application parameter
|
13
|
+
# @param [String] client_id the application id as [registered on Cobot](https://www.cobot.me/oauth2_clients)
|
14
|
+
# @param [String] client_secret the application secret as [registered on Cobot](https://www.cobot.me/oauth2_clients)
|
15
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
16
|
+
client_options = {
|
17
|
+
:authorize_url => 'https://www.cobot.me/oauth2/authorize',
|
18
|
+
:token_url => 'https://www.cobot.me/oauth2/access_token'
|
19
|
+
}
|
20
|
+
super(app, :cobot, client_id, client_secret, client_options, {:scope => 'read write'}.merge(options), &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def auth_hash
|
24
|
+
OmniAuth::Utils.deep_merge(
|
25
|
+
super, {
|
26
|
+
'uid' => user_data['login'],
|
27
|
+
'user_info' => user_info,
|
28
|
+
'extra' => {
|
29
|
+
'user_hash' => user_data,
|
30
|
+
}
|
31
|
+
}
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def user_data
|
36
|
+
@data ||= MultiJson.decode(@access_token.get('https://www.cobot.me/api/user').body)
|
37
|
+
end
|
38
|
+
|
39
|
+
# OAuth2 by default uses 'Bearer %s' in the header
|
40
|
+
def build_access_token
|
41
|
+
access_token = super
|
42
|
+
access_token.options[:header_format] = "OAuth %s"
|
43
|
+
access_token
|
44
|
+
end
|
45
|
+
|
46
|
+
def user_info
|
47
|
+
{
|
48
|
+
'name' => user_data['login'],
|
49
|
+
'email' => user_data['email']
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -3,30 +3,37 @@ require 'multi_json'
|
|
3
3
|
|
4
4
|
module OmniAuth
|
5
5
|
module Strategies
|
6
|
-
#
|
7
6
|
# Authenticate to DailyMile utilizing OAuth 2.0 and retrieve
|
8
7
|
# basic user information.
|
9
8
|
#
|
10
9
|
# @example Basic Usage
|
11
|
-
# use OmniAuth::Strategies::DailyMile, '
|
12
|
-
class Dailymile < OAuth2
|
10
|
+
# use OmniAuth::Strategies::DailyMile, 'client_id', 'CLIENT_SECRET'
|
11
|
+
class Dailymile < OmniAuth::Strategies::OAuth2
|
13
12
|
# @param [Rack Application] app standard middleware application parameter
|
14
13
|
# @param [String] client_id the application id as [registered on Dailymile](http://www.dailymile.com/api/consumers/new)
|
15
14
|
# @param [String] cliend_secret the application secret as [registered on Dailymile](http://www.dailymile.com/api/consumers/new)
|
16
|
-
def initialize(app, client_id
|
15
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
17
16
|
client_options = {
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:access_token_path => '/oauth/token'
|
17
|
+
:authorize_url => 'https://api.dailymile.com/oauth/authorize',
|
18
|
+
:token_url => 'https://api.dailymile.com/oauth/token',
|
21
19
|
}
|
22
|
-
|
23
20
|
super(app, :dailymile, client_id, client_secret, client_options, options, &block)
|
24
21
|
end
|
25
22
|
|
26
|
-
|
23
|
+
def auth_hash
|
24
|
+
OmniAuth::Utils.deep_merge(
|
25
|
+
super, {
|
26
|
+
'uid' => user_data['url'].split('/').last,
|
27
|
+
'user_info' => user_info,
|
28
|
+
'extra' => {
|
29
|
+
'user_hash' => user_data,
|
30
|
+
},
|
31
|
+
}
|
32
|
+
)
|
33
|
+
end
|
27
34
|
|
28
35
|
def user_data
|
29
|
-
@data ||= MultiJson.decode(@access_token.get(
|
36
|
+
@data ||= MultiJson.decode(@access_token.get('/people/me.json'))
|
30
37
|
end
|
31
38
|
|
32
39
|
def request_phase
|
@@ -47,18 +54,10 @@ module OmniAuth
|
|
47
54
|
'image' => user_data['photo_url'],
|
48
55
|
'description' => user_data['goal'],
|
49
56
|
'urls' => {
|
50
|
-
'dailymile' => user_data['url']
|
51
|
-
}
|
57
|
+
'dailymile' => user_data['url'],
|
58
|
+
},
|
52
59
|
}
|
53
60
|
end
|
54
|
-
|
55
|
-
def auth_hash
|
56
|
-
OmniAuth::Utils.deep_merge(super, {
|
57
|
-
'uid' => user_data["url"].split('/').last,
|
58
|
-
'user_info' => user_info,
|
59
|
-
'extra' => {'user_hash' => user_data}
|
60
|
-
})
|
61
|
-
end
|
62
61
|
end
|
63
62
|
end
|
64
63
|
end
|
@@ -3,25 +3,33 @@ require 'multi_json'
|
|
3
3
|
|
4
4
|
module OmniAuth
|
5
5
|
module Strategies
|
6
|
-
class Doit < OAuth2
|
7
|
-
def initialize(app,
|
6
|
+
class Doit < OmniAuth::Strategies::OAuth2
|
7
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
8
8
|
client_options = {
|
9
|
-
:site => 'https://openapi.doit.im',
|
10
9
|
:authorize_url => 'https://openapi.doit.im/oauth/authorize',
|
11
|
-
:
|
10
|
+
:token_url => 'https://openapi.doit.im/oauth/access_token',
|
12
11
|
}
|
13
|
-
|
14
|
-
super(app, :doit, consumer_key, consumer_secret, client_options, options, &block)
|
12
|
+
super(app, :doit, client_id, client_secret, client_options, options, &block)
|
15
13
|
end
|
16
14
|
|
17
|
-
|
15
|
+
def auth_hash
|
16
|
+
OmniAuth::Utils.deep_merge(
|
17
|
+
super, {
|
18
|
+
'uid' => user_data['id'],
|
19
|
+
'user_info' => user_info,
|
20
|
+
'extra' => {
|
21
|
+
'user_hash' => user_data,
|
22
|
+
},
|
23
|
+
}
|
24
|
+
)
|
25
|
+
end
|
18
26
|
|
19
27
|
def user_data
|
20
|
-
@data ||= MultiJson.decode(@access_token.get(
|
28
|
+
@data ||= MultiJson.decode(@access_token.get('https://openapi.doit.im/v1/settings'), {'Authorization' => 'OAuth' + @access_token.token})
|
21
29
|
end
|
22
30
|
|
23
31
|
def request_phase
|
24
|
-
options[:response_type] ||=
|
32
|
+
options[:response_type] ||= 'code'
|
25
33
|
super
|
26
34
|
end
|
27
35
|
|
@@ -44,17 +52,9 @@ module OmniAuth
|
|
44
52
|
'user_timezone'=> user_data['user_timezone'],
|
45
53
|
'remind_email'=> user_data['remind_email'],
|
46
54
|
'created'=> user_data['created'],
|
47
|
-
'updated'=> user_data['updated']
|
55
|
+
'updated'=> user_data['updated'],
|
48
56
|
}
|
49
57
|
end
|
50
|
-
|
51
|
-
def auth_hash
|
52
|
-
OmniAuth::Utils.deep_merge(super, {
|
53
|
-
'uid' => user_data['id'],
|
54
|
-
'user_info' => user_info,
|
55
|
-
'extra' => {'user_hash' => user_data}
|
56
|
-
})
|
57
|
-
end
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -8,21 +8,46 @@ module OmniAuth
|
|
8
8
|
#
|
9
9
|
# @example Basic Usage
|
10
10
|
# use OmniAuth::Strategies::Facebook, 'client_id', 'client_secret'
|
11
|
-
class Facebook < OAuth2
|
11
|
+
class Facebook < OmniAuth::Strategies::OAuth2
|
12
12
|
# @param [Rack Application] app standard middleware application parameter
|
13
13
|
# @param [String] client_id the application id as [registered on Facebook](http://www.facebook.com/developers/)
|
14
14
|
# @param [String] client_secret the application secret as registered on Facebook
|
15
15
|
# @option options [String] :scope ('email,offline_access') comma-separated extended permissions such as `email` and `manage_pages`
|
16
|
-
def initialize(app, client_id
|
17
|
-
|
16
|
+
def initialize(app, client_id=nil, client_secret=nil, options = {}, &block)
|
17
|
+
client_options = {
|
18
|
+
:site => 'https://graph.facebook.com/',
|
19
|
+
:token_url => '/oauth/access_token'
|
20
|
+
}
|
21
|
+
|
22
|
+
options = {
|
23
|
+
:parse => :query
|
24
|
+
}.merge(options)
|
25
|
+
|
26
|
+
super(app, :facebook, client_id, client_secret, client_options, options, &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def auth_hash
|
30
|
+
OmniAuth::Utils.deep_merge(
|
31
|
+
super, {
|
32
|
+
'uid' => user_data['id'],
|
33
|
+
'user_info' => user_info,
|
34
|
+
'extra' => {
|
35
|
+
'user_hash' => user_data,
|
36
|
+
},
|
37
|
+
}
|
38
|
+
)
|
18
39
|
end
|
19
40
|
|
20
41
|
def user_data
|
21
|
-
@
|
42
|
+
@access_token.options[:mode] = :query
|
43
|
+
@access_token.options[:param_name] = 'access_token'
|
44
|
+
@data ||= @access_token.get('/me').parsed
|
45
|
+
rescue ::OAuth2::Error => e
|
46
|
+
raise e.response.inspect
|
22
47
|
end
|
23
48
|
|
24
49
|
def request_phase
|
25
|
-
options[:scope] ||=
|
50
|
+
options[:scope] ||= 'email,offline_access'
|
26
51
|
super
|
27
52
|
end
|
28
53
|
|
@@ -30,7 +55,7 @@ module OmniAuth
|
|
30
55
|
if facebook_session.nil? || facebook_session.empty?
|
31
56
|
super
|
32
57
|
else
|
33
|
-
@access_token = ::OAuth2::AccessToken.new(client, facebook_session['access_token'])
|
58
|
+
@access_token = ::OAuth2::AccessToken.new(client, facebook_session['access_token'], {:mode => :query, :param_name => 'access_token'})
|
34
59
|
end
|
35
60
|
end
|
36
61
|
|
@@ -45,26 +70,18 @@ module OmniAuth
|
|
45
70
|
|
46
71
|
def user_info
|
47
72
|
{
|
48
|
-
'nickname' => user_data[
|
49
|
-
'email' => (user_data[
|
50
|
-
'first_name' => user_data[
|
51
|
-
'last_name' => user_data[
|
73
|
+
'nickname' => user_data['username'],
|
74
|
+
'email' => (user_data['email'] if user_data['email']),
|
75
|
+
'first_name' => user_data['first_name'],
|
76
|
+
'last_name' => user_data['last_name'],
|
52
77
|
'name' => "#{user_data['first_name']} #{user_data['last_name']}",
|
53
78
|
'image' => "http://graph.facebook.com/#{user_data['id']}/picture?type=square",
|
54
79
|
'urls' => {
|
55
|
-
'Facebook' => user_data[
|
56
|
-
'Website' => user_data[
|
57
|
-
}
|
80
|
+
'Facebook' => user_data['link'],
|
81
|
+
'Website' => user_data['website'],
|
82
|
+
},
|
58
83
|
}
|
59
84
|
end
|
60
|
-
|
61
|
-
def auth_hash
|
62
|
-
OmniAuth::Utils.deep_merge(super, {
|
63
|
-
'uid' => user_data['id'],
|
64
|
-
'user_info' => user_info,
|
65
|
-
'extra' => {'user_hash' => user_data}
|
66
|
-
})
|
67
|
-
end
|
68
85
|
end
|
69
86
|
end
|
70
87
|
end
|
@@ -3,18 +3,30 @@ require 'multi_json'
|
|
3
3
|
|
4
4
|
module OmniAuth
|
5
5
|
module Strategies
|
6
|
-
class Foursquare < OAuth2
|
6
|
+
class Foursquare < OmniAuth::Strategies::OAuth2
|
7
7
|
# Initialize the middleware
|
8
8
|
#
|
9
9
|
# @option options [Boolean, true] :sign_in When true, use a sign-in flow instead of the authorization flow.
|
10
10
|
# @option options [Boolean, false] :mobile When true, use the mobile sign-in interface.
|
11
|
-
def initialize(app, client_id
|
11
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
12
12
|
options[:sign_in] ||= true
|
13
|
-
|
14
|
-
:
|
15
|
-
:
|
16
|
-
|
17
|
-
|
13
|
+
client_options = {
|
14
|
+
:authorize_url => authorize_url(options),
|
15
|
+
:token_url => 'https://foursquare.com/oauth2/access_token',
|
16
|
+
}
|
17
|
+
super(app, :foursquare, 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['response']['user']['id'],
|
24
|
+
'user_info' => user_info,
|
25
|
+
'extra' => {
|
26
|
+
'user_hash' => user_data['response']['user'],
|
27
|
+
},
|
28
|
+
}
|
29
|
+
)
|
18
30
|
end
|
19
31
|
|
20
32
|
def authorize_url(options)
|
@@ -22,7 +34,7 @@ module OmniAuth
|
|
22
34
|
end
|
23
35
|
|
24
36
|
def user_data
|
25
|
-
@data ||= MultiJson.decode(@access_token.get(
|
37
|
+
@data ||= MultiJson.decode(@access_token.get('https://api.foursquare.com/v2/users/self', { :params => { 'oauth_token' => @access_token.token } }).body)
|
26
38
|
end
|
27
39
|
|
28
40
|
def request_phase
|
@@ -42,21 +54,10 @@ module OmniAuth
|
|
42
54
|
'last_name' => user_data['response']['user']['lastName'],
|
43
55
|
'email' => user_data['response']['user']['contact']['email'],
|
44
56
|
'name' => "#{user_data['response']['user']['firstName']} #{user_data['response']['user']['lastName']}".strip,
|
45
|
-
# 'location' => user_data['response']['user']['location'],
|
46
57
|
'image' => user_data['response']['user']['photo'],
|
47
|
-
# 'description' => user_data['response']['user']['description'],
|
48
58
|
'phone' => user_data['response']['user']['contact']['phone'],
|
49
|
-
'urls' => {}
|
50
59
|
}
|
51
60
|
end
|
52
|
-
|
53
|
-
def auth_hash
|
54
|
-
OmniAuth::Utils.deep_merge(super, {
|
55
|
-
'uid' => user_data['response']['user']['id'],
|
56
|
-
'user_info' => user_info,
|
57
|
-
'extra' => {'user_hash' => user_data['response']['user']}
|
58
|
-
})
|
59
|
-
end
|
60
61
|
end
|
61
62
|
end
|
62
63
|
end
|
@@ -6,45 +6,47 @@ module OmniAuth
|
|
6
6
|
# OAuth 2.0 based authentication with GitHub. In order to
|
7
7
|
# sign up for an application, you need to [register an application](http://github.com/account/applications/new)
|
8
8
|
# and provide the proper credentials to this middleware.
|
9
|
-
class GitHub < OAuth2
|
9
|
+
class GitHub < OmniAuth::Strategies::OAuth2
|
10
10
|
# @param [Rack Application] app standard middleware application argument
|
11
11
|
# @param [String] client_id the application ID for your client
|
12
12
|
# @param [String] client_secret the application secret
|
13
|
-
def initialize(app, client_id
|
13
|
+
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
|
14
14
|
client_options = {
|
15
|
-
:site => 'https://github.com
|
16
|
-
:
|
17
|
-
:
|
15
|
+
:site => 'https://api.github.com',
|
16
|
+
:authorize_url => 'https://github.com/login/oauth/authorize',
|
17
|
+
:token_url => 'https://github.com/login/oauth/access_token'
|
18
18
|
}
|
19
|
-
|
20
19
|
super(app, :github, client_id, client_secret, client_options, options, &block)
|
21
20
|
end
|
22
21
|
|
23
|
-
|
22
|
+
def auth_hash
|
23
|
+
OmniAuth::Utils.deep_merge(
|
24
|
+
super, {
|
25
|
+
'uid' => user_data['id'],
|
26
|
+
'user_info' => user_info,
|
27
|
+
'extra' => {
|
28
|
+
'user_hash' => user_data,
|
29
|
+
},
|
30
|
+
}
|
31
|
+
)
|
32
|
+
end
|
24
33
|
|
25
34
|
def user_data
|
26
|
-
@
|
35
|
+
@access_token.options[:mode] = :query
|
36
|
+
@data ||= @access_token.get('/user').parsed
|
27
37
|
end
|
28
38
|
|
29
39
|
def user_info
|
30
40
|
{
|
31
|
-
'nickname' => user_data[
|
41
|
+
'nickname' => user_data['login'],
|
32
42
|
'email' => user_data['email'],
|
33
43
|
'name' => user_data['name'],
|
34
44
|
'urls' => {
|
35
45
|
'GitHub' => "http://github.com/#{user_data['login']}",
|
36
|
-
'Blog' => user_data[
|
37
|
-
}
|
46
|
+
'Blog' => user_data['blog'],
|
47
|
+
},
|
38
48
|
}
|
39
49
|
end
|
40
|
-
|
41
|
-
def auth_hash
|
42
|
-
OmniAuth::Utils.deep_merge(super, {
|
43
|
-
'uid' => user_data['id'],
|
44
|
-
'user_info' => user_info,
|
45
|
-
'extra' => {'user_hash' => user_data}
|
46
|
-
})
|
47
|
-
end
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|