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.
Files changed (143) hide show
  1. data/Gemfile +4 -0
  2. data/lib/omniauth/oauth.rb +65 -47
  3. data/lib/omniauth/strategies/google_oauth2.rb +59 -0
  4. data/lib/omniauth/strategies/oauth.rb +8 -2
  5. data/lib/omniauth/strategies/oauth/blogger.rb +58 -0
  6. data/lib/omniauth/strategies/{dopplr.rb → oauth/dopplr.rb} +19 -21
  7. data/lib/omniauth/strategies/{douban.rb → oauth/douban.rb} +18 -18
  8. data/lib/omniauth/strategies/oauth/dropbox.rb +40 -0
  9. data/lib/omniauth/strategies/{evernote.rb → oauth/evernote.rb} +11 -13
  10. data/lib/omniauth/strategies/oauth/flattr.rb +47 -0
  11. data/lib/omniauth/strategies/oauth/flickr.rb +39 -0
  12. data/lib/omniauth/strategies/{goodreads.rb → oauth/goodreads.rb} +9 -9
  13. data/lib/omniauth/strategies/{google.rb → oauth/google.rb} +19 -20
  14. data/lib/omniauth/strategies/oauth/google_health.rb +71 -0
  15. data/lib/omniauth/strategies/oauth/google_health_sandbox.rb +74 -0
  16. data/lib/omniauth/strategies/oauth/hyves.rb +69 -0
  17. data/lib/omniauth/strategies/{identica.rb → oauth/identica.rb} +20 -16
  18. data/lib/omniauth/strategies/{linked_in.rb → oauth/linked_in.rb} +14 -14
  19. data/lib/omniauth/strategies/{meetup.rb → oauth/meetup.rb} +18 -16
  20. data/lib/omniauth/strategies/{miso.rb → oauth/miso.rb} +14 -7
  21. data/lib/omniauth/strategies/{netflix.rb → oauth/netflix.rb} +16 -14
  22. data/lib/omniauth/strategies/oauth/orkut.rb +63 -0
  23. data/lib/omniauth/strategies/oauth/plurk.rb +57 -0
  24. data/lib/omniauth/strategies/{qzone.rb → oauth/qzone.rb} +15 -12
  25. data/lib/omniauth/strategies/oauth/rdio.rb +48 -0
  26. data/lib/omniauth/strategies/oauth/smug_mug.rb +47 -0
  27. data/lib/omniauth/strategies/{t163.rb → oauth/t163.rb} +17 -17
  28. data/lib/omniauth/strategies/oauth/tqq.rb +63 -0
  29. data/lib/omniauth/strategies/oauth/trade_me.rb +50 -0
  30. data/lib/omniauth/strategies/oauth/trip_it.rb +24 -0
  31. data/lib/omniauth/strategies/{tsina.rb → oauth/tsina.rb} +21 -15
  32. data/lib/omniauth/strategies/{tsohu.rb → oauth/tsohu.rb} +15 -17
  33. data/lib/omniauth/strategies/{tumblr.rb → oauth/tumblr.rb} +13 -15
  34. data/lib/omniauth/strategies/{twitter.rb → oauth/twitter.rb} +17 -16
  35. data/lib/omniauth/strategies/{type_pad.rb → oauth/type_pad.rb} +18 -27
  36. data/lib/omniauth/strategies/{vimeo.rb → oauth/vimeo.rb} +18 -14
  37. data/lib/omniauth/strategies/{yahoo.rb → oauth/yahoo.rb} +17 -12
  38. data/lib/omniauth/strategies/{yammer.rb → oauth/yammer.rb} +17 -12
  39. data/lib/omniauth/strategies/{you_tube.rb → oauth/you_tube.rb} +16 -14
  40. data/lib/omniauth/strategies/oauth2.rb +7 -5
  41. data/lib/omniauth/strategies/oauth2/angellist.rb +57 -0
  42. data/lib/omniauth/strategies/oauth2/bitly.rb +43 -0
  43. data/lib/omniauth/strategies/oauth2/cobot.rb +54 -0
  44. data/lib/omniauth/strategies/{dailymile.rb → oauth2/dailymile.rb} +19 -20
  45. data/lib/omniauth/strategies/{doit.rb → oauth2/doit.rb} +18 -18
  46. data/lib/omniauth/strategies/{facebook.rb → oauth2/facebook.rb} +38 -21
  47. data/lib/omniauth/strategies/{foursquare.rb → oauth2/foursquare.rb} +20 -19
  48. data/lib/omniauth/strategies/{github.rb → oauth2/github.rb} +21 -19
  49. data/lib/omniauth/strategies/oauth2/glitch.rb +45 -0
  50. data/lib/omniauth/strategies/oauth2/gowalla.rb +72 -0
  51. data/lib/omniauth/strategies/{instagram.rb → oauth2/instagram.rb} +19 -17
  52. data/lib/omniauth/strategies/oauth2/liveid.rb +67 -0
  53. data/lib/omniauth/strategies/oauth2/mailchimp.rb +39 -0
  54. data/lib/omniauth/strategies/oauth2/mailru.rb +75 -0
  55. data/lib/omniauth/strategies/{mixi.rb → oauth2/mixi.rb} +23 -18
  56. data/lib/omniauth/strategies/{renren.rb → oauth2/renren.rb} +25 -23
  57. data/lib/omniauth/strategies/oauth2/salesforce.rb +48 -0
  58. data/lib/omniauth/strategies/oauth2/sound_cloud.rb +60 -0
  59. data/lib/omniauth/strategies/{taobao.rb → oauth2/taobao.rb} +24 -22
  60. data/lib/omniauth/strategies/{teambox.rb → oauth2/teambox.rb} +19 -17
  61. data/lib/omniauth/strategies/{thirty_seven_signals.rb → oauth2/thirty_seven_signals.rb} +17 -17
  62. data/lib/omniauth/strategies/oauth2/viadeo.rb +72 -0
  63. data/lib/omniauth/strategies/oauth2/vkontakte.rb +104 -0
  64. data/lib/omniauth/strategies/oauth2/we_pay.rb +48 -0
  65. data/lib/omniauth/strategies/xauth.rb +3 -3
  66. data/lib/omniauth/strategies/{instapaper.rb → xauth/instapaper.rb} +9 -12
  67. data/lib/omniauth/version.rb +3 -3
  68. data/oa-oauth.gemspec +17 -18
  69. data/spec/omniauth/strategies/{bitly_spec.rb → google_oauth2_spec.rb} +1 -1
  70. data/spec/omniauth/strategies/{dopplr_spec.rb → oauth/dopplr_spec.rb} +1 -1
  71. data/spec/omniauth/strategies/{douban_spec.rb → oauth/douban_spec.rb} +1 -1
  72. data/spec/omniauth/strategies/oauth/dropbox_spec.rb +5 -0
  73. data/spec/omniauth/strategies/{evernote_spec.rb → oauth/evernote_spec.rb} +1 -1
  74. data/spec/omniauth/strategies/oauth/flattr_spec.rb +5 -0
  75. data/spec/omniauth/strategies/oauth/flickr_spec.rb +6 -0
  76. data/spec/omniauth/strategies/{goodreads_spec.rb → oauth/goodreads_spec.rb} +1 -1
  77. data/spec/omniauth/strategies/oauth/google_health_sandbox_spec.rb +5 -0
  78. data/spec/omniauth/strategies/oauth/google_health_spec.rb +5 -0
  79. data/spec/omniauth/strategies/{google_spec.rb → oauth/google_spec.rb} +1 -1
  80. data/spec/omniauth/strategies/{hyves_spec.rb → oauth/hyves_spec.rb} +1 -1
  81. data/spec/omniauth/strategies/{identica_spec.rb → oauth/identica_spec.rb} +1 -1
  82. data/spec/omniauth/strategies/{linked_in_spec.rb → oauth/linked_in_spec.rb} +1 -1
  83. data/spec/omniauth/strategies/{meetup_spec.rb → oauth/meetup_spec.rb} +3 -3
  84. data/spec/omniauth/strategies/{miso_spec.rb → oauth/miso_spec.rb} +1 -1
  85. data/spec/omniauth/strategies/{netflix_spec.rb → oauth/netflix_spec.rb} +1 -1
  86. data/spec/omniauth/strategies/oauth/oauth_spec.rb +131 -0
  87. data/spec/omniauth/strategies/oauth/orkut_spec.rb +5 -0
  88. data/spec/omniauth/strategies/{plurk_spec.rb → oauth/plurk_spec.rb} +1 -1
  89. data/spec/omniauth/strategies/{rdio_spec.rb → oauth/rdio_spec.rb} +1 -1
  90. data/spec/omniauth/strategies/{smug_mug_spec.rb → oauth/smug_mug_spec.rb} +1 -1
  91. data/spec/omniauth/strategies/{t163_spec.rb → oauth/t163_spec.rb} +1 -1
  92. data/spec/omniauth/strategies/{trade_me_spec.rb → oauth/trade_me_spec.rb} +1 -1
  93. data/spec/omniauth/strategies/{trip_it_spec.rb → oauth/trip_it_spec.rb} +1 -1
  94. data/spec/omniauth/strategies/{tsina_spec.rb → oauth/tsina_spec.rb} +1 -1
  95. data/spec/omniauth/strategies/{tumblr_spec.rb → oauth/tumblr_spec.rb} +1 -1
  96. data/spec/omniauth/strategies/oauth/twitter_spec.rb +43 -0
  97. data/spec/omniauth/strategies/{type_pad_spec.rb → oauth/type_pad_spec.rb} +1 -1
  98. data/spec/omniauth/strategies/{vimeo_spec.rb → oauth/vimeo_spec.rb} +1 -1
  99. data/spec/omniauth/strategies/{yahoo_spec.rb → oauth/yahoo_spec.rb} +1 -1
  100. data/spec/omniauth/strategies/{yammer_spec.rb → oauth/yammer_spec.rb} +1 -1
  101. data/spec/omniauth/strategies/{you_tube_spec.rb → oauth/you_tube_spec.rb} +1 -1
  102. data/spec/omniauth/strategies/oauth2/angellist_spec.rb +5 -0
  103. data/spec/omniauth/strategies/oauth2/bitly_spec.rb +5 -0
  104. data/spec/omniauth/strategies/oauth2/cobot_spec.rb +5 -0
  105. data/spec/omniauth/strategies/{dailymile_spec.rb → oauth2/dailymile_spec.rb} +1 -1
  106. data/spec/omniauth/strategies/{doit_spec.rb → oauth2/doit_spec.rb} +1 -1
  107. data/spec/omniauth/strategies/{facebook_spec.rb → oauth2/facebook_spec.rb} +1 -1
  108. data/spec/omniauth/strategies/{foursquare_spec.rb → oauth2/foursquare_spec.rb} +1 -1
  109. data/spec/omniauth/strategies/{github_spec.rb → oauth2/github_spec.rb} +1 -1
  110. data/spec/omniauth/strategies/oauth2/glitch_spec.rb +5 -0
  111. data/spec/omniauth/strategies/{gowalla_spec.rb → oauth2/gowalla_spec.rb} +1 -1
  112. data/spec/omniauth/strategies/oauth2/instagram_spec.rb +5 -0
  113. data/spec/omniauth/strategies/oauth2/liveid_spec.rb +5 -0
  114. data/spec/omniauth/strategies/oauth2/mailchimp_spec.rb +6 -0
  115. data/spec/omniauth/strategies/{mailru_spec.rb → oauth2/mailru_spec.rb} +1 -1
  116. data/spec/omniauth/strategies/{salesforce_spec.rb → oauth2/salesforce_spec.rb} +1 -1
  117. data/spec/omniauth/strategies/oauth2/sound_cloud_spec.rb +5 -0
  118. data/spec/omniauth/strategies/oauth2/taobao_spec.rb +5 -0
  119. data/spec/omniauth/strategies/{teambox_spec.rb → oauth2/teambox_spec.rb} +1 -1
  120. data/spec/omniauth/strategies/{thirty_seven_signals_spec.rb → oauth2/thirty_seven_signals_spec.rb} +1 -1
  121. data/spec/omniauth/strategies/oauth2/viadeo_spec.rb +5 -0
  122. data/spec/omniauth/strategies/{vkontakte_spec.rb → oauth2/vkontakte_spec.rb} +1 -1
  123. data/spec/omniauth/strategies/oauth2/we_pay_spec.rb +5 -0
  124. data/spec/spec_helper.rb +4 -0
  125. metadata +277 -151
  126. data/lib/omniauth/strategies/bitly.rb +0 -46
  127. data/lib/omniauth/strategies/gowalla.rb +0 -72
  128. data/lib/omniauth/strategies/hyves.rb +0 -67
  129. data/lib/omniauth/strategies/mailru.rb +0 -107
  130. data/lib/omniauth/strategies/plurk.rb +0 -58
  131. data/lib/omniauth/strategies/rdio.rb +0 -45
  132. data/lib/omniauth/strategies/salesforce.rb +0 -44
  133. data/lib/omniauth/strategies/smug_mug.rb +0 -42
  134. data/lib/omniauth/strategies/sound_cloud.rb +0 -46
  135. data/lib/omniauth/strategies/tqq.rb +0 -64
  136. data/lib/omniauth/strategies/trade_me.rb +0 -45
  137. data/lib/omniauth/strategies/trip_it.rb +0 -22
  138. data/lib/omniauth/strategies/vkontakte.rb +0 -87
  139. data/spec/omniauth/strategies/oauth2_spec.rb +0 -0
  140. data/spec/omniauth/strategies/oauth_spec.rb +0 -77
  141. data/spec/omniauth/strategies/sound_cloud_spec.rb +0 -5
  142. data/spec/omniauth/strategies/taobao_spec.rb +0 -5
  143. data/spec/omniauth/strategies/twitter_spec.rb +0 -20
@@ -0,0 +1,48 @@
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ # Authenticate to Rdio via OAuth and retrieve basic user information.
7
+ #
8
+ # Usage:
9
+ # use OmniAuth::Strategies::Rdio, 'consumerkey', 'consumersecret'
10
+ class Rdio < OmniAuth::Strategies::OAuth
11
+ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
12
+ client_options = {
13
+ :access_token_path => '/oauth/access_token',
14
+ :authorize_url => 'https://www.rdio.com/oauth/authorize',
15
+ :request_token_path => '/oauth/request_token',
16
+ :site => 'http://api.rdio.com',
17
+ }
18
+ super(app, :rdio, consumer_key, consumer_secret, client_options, options, &block)
19
+ end
20
+
21
+ def auth_hash
22
+ OmniAuth::Utils.deep_merge(
23
+ super, {
24
+ 'uid' => user_hash['key'],
25
+ 'user_info' => user_info,
26
+ 'extra' => {
27
+ 'user_hash' => user_hash,
28
+ },
29
+ }
30
+ )
31
+ end
32
+
33
+ def user_info
34
+ user = user_hash
35
+ {
36
+ 'nickname' => user['username'],
37
+ 'first_name' => user['firstName'],
38
+ 'last_name' => user['lastName'],
39
+ 'name' => "#{user['firstName']} #{user['lastName']}"
40
+ }
41
+ end
42
+
43
+ def user_hash
44
+ @user_hash ||= MultiJson.decode(@access_token.post('http://api.rdio.com/1/', {:method => 'currentUser', :extras => 'username'}).body)['result']
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,47 @@
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ # Authenticate to SmugMug via OAuth and retrieve basic user information.
7
+ #
8
+ # Usage:
9
+ # use OmniAuth::Strategies::SmugMug, 'consumerkey', 'consumersecret'
10
+ class SmugMug < OmniAuth::Strategies::OAuth
11
+ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
12
+ client_options = {
13
+ :access_token_path => '/services/oauth/getAccessToken.mg',
14
+ :authorize_path => '/services/oauth/authorize.mg',
15
+ :site => 'http://api.smugmug.com',
16
+ :request_token_path => '/services/oauth/getRequestToken.mg',
17
+ }
18
+ super(app, :smugmug, consumer_key, consumer_secret, client_options, options, &block)
19
+ end
20
+
21
+ def auth_hash
22
+ OmniAuth::Utils.deep_merge(
23
+ super, {
24
+ 'uid' => user_hash['id'],
25
+ 'user_info' => user_info,
26
+ 'extra' => {
27
+ 'user_hash' => user_hash,
28
+ },
29
+ }
30
+ )
31
+ end
32
+
33
+ # user info according to schema
34
+ def user_info
35
+ {
36
+ 'nickname' => user_hash['NickName'],
37
+ 'name' => user_hash['NickName']
38
+ }
39
+ end
40
+
41
+ # info as supplied by SmugMug
42
+ def user_hash
43
+ @user_hash ||= MultiJson.decode(@access_token.get('/services/api/json/1.2.2/?method=smugmug.auth.checkAccessToken').body)['Auth']['User']
44
+ end
45
+ end
46
+ end
47
+ end
@@ -3,36 +3,35 @@ require 'multi_json'
3
3
 
4
4
  module OmniAuth
5
5
  module Strategies
6
- #
7
6
  # Authenticate to T163 via OAuth and retrieve basic
8
7
  # user information.
9
8
  #
10
9
  # Usage:
11
10
  #
12
11
  # use OmniAuth::Strategies::T163, 'APIKey', 'APIKeySecret'
13
- #
14
12
  class T163 < OmniAuth::Strategies::OAuth
15
-
16
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
13
+ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
17
14
  @api_key = consumer_key
18
-
19
15
  client_options = {
20
- :site => 'http://api.t.163.com',
16
+ :access_token_path => '/oauth/access_token',
17
+ :authorize_path => '/oauth/authenticate',
18
+ :realm => 'OmniAuth',
21
19
  :request_token_path => '/oauth/request_token',
22
- :access_token_path => '/oauth/access_token',
23
- :authorize_path => '/oauth/authenticate',
24
- :realm => 'OmniAuth'
20
+ :site => 'http://api.t.163.com',
25
21
  }
26
-
27
22
  super(app, :t163, consumer_key, consumer_secret, client_options, options, &block)
28
23
  end
29
24
 
30
25
  def auth_hash
31
- OmniAuth::Utils.deep_merge(super, {
32
- 'uid' => user_hash['screen_name'],
33
- 'user_info' => user_info,
34
- 'extra' => {'user_hash' => user_hash}
35
- })
26
+ OmniAuth::Utils.deep_merge(
27
+ super, {
28
+ 'uid' => user_hash['screen_name'],
29
+ 'user_info' => user_info,
30
+ 'extra' => {
31
+ 'user_hash' => user_hash,
32
+ },
33
+ }
34
+ )
36
35
  end
37
36
 
38
37
  def user_info
@@ -43,9 +42,10 @@ module OmniAuth
43
42
  'location' => user_hash['location'],
44
43
  'image' => user_hash['profile_image_url'],
45
44
  'description' => user_hash['description'],
45
+ 'email' => user_hash['email'],
46
46
  'urls' => {
47
- 'T163' => 'http://t.163.com'
48
- }
47
+ 'T163' => 'http://t.163.com',
48
+ },
49
49
  }
50
50
  end
51
51
 
@@ -0,0 +1,63 @@
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ # Authenticate to Tqq via OAuth and retrieve basic
7
+ # user information.
8
+ #
9
+ # Usage:
10
+ # use OmniAuth::Strategies::Tqq, 'APIKey', 'APIKeySecret'
11
+ class Tqq < OmniAuth::Strategies::OAuth
12
+
13
+ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
14
+ @api_key = consumer_key
15
+ client_options = {
16
+ :access_token_path => '/cgi-bin/access_token',
17
+ :authorize_path => '/cgi-bin/authorize',
18
+ :http_method => :get,
19
+ :nonce => nonce,
20
+ :realm => 'OmniAuth',
21
+ :request_token_path => '/cgi-bin/request_token',
22
+ :scheme => :query_string,
23
+ :site => 'https://open.t.qq.com',
24
+ }
25
+ super(app, :tqq, consumer_key, consumer_secret, client_options, options, &block)
26
+ end
27
+
28
+ def nonce
29
+ Base64.encode64(OpenSSL::Random.random_bytes(32)).gsub(/\W/, '')[0, 32]
30
+ end
31
+
32
+ def auth_hash
33
+ OmniAuth::Utils.deep_merge(
34
+ super, {
35
+ 'uid' => user_hash['data']['uid'],
36
+ 'user_info' => user_info,
37
+ 'extra' => {
38
+ 'user_hash' => user_hash,
39
+ },
40
+ }
41
+ )
42
+ end
43
+
44
+ def user_info
45
+ user_hash = self.user_hash
46
+ {
47
+ 'username' => user_hash['data']['name'],
48
+ 'name' => user_hash['data']['nick'],
49
+ 'location' => user_hash['data']['location'],
50
+ 'image' => user_hash['data']['head'],
51
+ 'description' => user_hash['description'],
52
+ 'urls' => {
53
+ 'Tqq' => 't.qq.com',
54
+ },
55
+ }
56
+ end
57
+
58
+ def user_hash
59
+ @user_hash ||= MultiJson.decode(@access_token.get('http://open.t.qq.com/api/user/info?format=json').body)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,50 @@
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ #
7
+ # Authenticate to TradeMe via OAuth and retrieve basic user information.
8
+ # Usage:
9
+ # use OmniAuth::Strategies::TradeMe, 'consumerkey', 'consumersecret'
10
+ #
11
+ class TradeMe < OmniAuth::Strategies::OAuth
12
+ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
13
+ client_options = {
14
+ :access_token_path => '/Oauth/AccessToken',
15
+ :authorize_path => '/Oauth/Authorize',
16
+ :request_token_path => '/Oauth/RequestToken',
17
+ :site => 'https://secure.trademe.co.nz',
18
+ }
19
+ super(app, :trademe, consumer_key, consumer_secret, client_options, options, &block)
20
+ end
21
+
22
+ def auth_hash
23
+ OmniAuth::Utils.deep_merge(
24
+ super, {
25
+ 'uid' => user_hash['MemberId'],
26
+ 'user_info' => user_info,
27
+ 'extra' => {
28
+ 'user_hash' => user_hash,
29
+ },
30
+ }
31
+ )
32
+ end
33
+
34
+ # user info according to schema
35
+ def user_info
36
+ {
37
+ 'nickname' => user_hash['Nickname'],
38
+ 'first_name' => user_hash['FirstName'],
39
+ 'last_name' => user_hash['LastName'],
40
+ 'name' => [user_hash['FirstName'], user_hash['LastName']].reject{|n| n.nil? || n.empty?}.join(' '),
41
+ }
42
+ end
43
+
44
+ # info as supplied by TradeMe user summary
45
+ def user_hash
46
+ @user_hash ||= MultiJson.decode(@access_token.get('https://api.trademe.co.nz/v1/MyTradeMe/Summary.json').body)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,24 @@
1
+ require 'omniauth/oauth'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ #
6
+ # Authenticate to TripIt via OAuth and retrieve an access token for API usage
7
+ #
8
+ # Usage:
9
+ #
10
+ # use OmniAuth::Strategies::TripIt, 'consumerkey', 'consumersecret'
11
+ #
12
+ class TripIt < OmniAuth::Strategies::OAuth
13
+ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
14
+ client_options = {
15
+ :access_token_path => '/oauth/access_token',
16
+ :authorize_url => 'https://www.tripit.com/oauth/authorize',
17
+ :request_token_path => '/oauth/request_token',
18
+ :site => 'https://api.tripit.com',
19
+ }
20
+ super(app, :tripit, consumer_key, consumer_secret, client_options, options, &block)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -3,36 +3,35 @@ require 'multi_json'
3
3
 
4
4
  module OmniAuth
5
5
  module Strategies
6
- #
7
6
  # Authenticate to TSina via OAuth and retrieve basic
8
7
  # user information.
9
8
  #
10
9
  # Usage:
11
- #
12
10
  # use OmniAuth::Strategies::TSina, 'APIKey', 'APIKeySecret'
13
- #
14
11
  class Tsina < OmniAuth::Strategies::OAuth
15
12
 
16
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
13
+ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
17
14
  @api_key = consumer_key
18
-
19
15
  client_options = {
20
- :site => 'http://api.t.sina.com.cn',
16
+ :access_token_path => '/oauth/access_token',
17
+ :authorize_path => '/oauth/authorize',
18
+ :realm => 'OmniAuth',
21
19
  :request_token_path => '/oauth/request_token',
22
- :access_token_path => '/oauth/access_token',
23
- :authorize_path => '/oauth/authorize',
24
- :realm => 'OmniAuth'
20
+ :site => 'http://api.t.sina.com.cn',
25
21
  }
26
-
27
22
  super(app, :tsina, consumer_key, consumer_secret, client_options, options, &block)
28
23
  end
29
24
 
30
25
  def auth_hash
31
- OmniAuth::Utils.deep_merge(super, {
32
- 'uid' => @access_token.params[:user_id],
33
- 'user_info' => user_info,
34
- 'extra' => {'user_hash' => user_hash}
35
- })
26
+ OmniAuth::Utils.deep_merge(
27
+ super, {
28
+ 'uid' => @access_token.params[:user_id],
29
+ 'user_info' => user_info,
30
+ 'extra' => {
31
+ 'user_hash' => user_hash,
32
+ },
33
+ }
34
+ )
36
35
  end
37
36
 
38
37
  def user_info
@@ -67,6 +66,13 @@ module OmniAuth
67
66
  fail!(:timeout, e)
68
67
  end
69
68
 
69
+ # MonkeyPath to symbolize tina parameters
70
+ def callback_phase
71
+ session[:oauth].stringify_keys!
72
+ session[:oauth][name.to_s].stringify_keys! if session[:oauth][name.to_s]
73
+ super
74
+ end
75
+
70
76
  def user_hash
71
77
  # http://api.t.sina.com.cn/users/show/:id.json?source=appkey
72
78
  # @access_token.params[:user_id] is the UID
@@ -3,36 +3,34 @@ require 'multi_json'
3
3
 
4
4
  module OmniAuth
5
5
  module Strategies
6
- #
7
6
  # Authenticate to Tsohu via OAuth and retrieve basic
8
7
  # user information.
9
8
  #
10
9
  # Usage:
11
- #
12
10
  # use OmniAuth::Strategies::Tsohu, 'APIKey', 'APIKeySecret'
13
- #
14
11
  class Tsohu < OmniAuth::Strategies::OAuth
15
-
16
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
12
+ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
17
13
  @api_key = consumer_key
18
-
19
14
  client_options = {
20
- :site => 'http://api.t.sohu.com',
15
+ :access_token_path => '/oauth/access_token',
16
+ :authorize_path => '/oauth/authorize',
17
+ :scheme => :header,
18
+ :site => 'http://api.t.sohu.com',
21
19
  :request_token_path => '/oauth/request_token',
22
- :access_token_path => '/oauth/access_token',
23
- :authorize_path => '/oauth/authorize',
24
- :scheme => :header,
25
20
  }
26
-
27
21
  super(app, :tsohu, consumer_key, consumer_secret, client_options, options, &block)
28
22
  end
29
23
 
30
24
  def auth_hash
31
- OmniAuth::Utils.deep_merge(super, {
32
- 'uid' => user_hash['id'],
33
- 'user_info' => user_info,
34
- 'extra' => {'user_hash' => user_hash}
35
- })
25
+ OmniAuth::Utils.deep_merge(
26
+ super, {
27
+ 'uid' => user_hash['id'],
28
+ 'user_info' => user_info,
29
+ 'extra' => {
30
+ 'user_hash' => user_hash,
31
+ },
32
+ }
33
+ )
36
34
  end
37
35
 
38
36
  def user_info
@@ -50,7 +48,7 @@ module OmniAuth
50
48
  end
51
49
 
52
50
  def user_hash
53
- @user_hash ||= MultiJson.decode(@access_token.get("http://api.t.sohu.com/account/verify_credentials.json").body)
51
+ @user_hash ||= MultiJson.decode(@access_token.get('http://api.t.sohu.com/account/verify_credentials.json').body)
54
52
  end
55
53
  end
56
54
  end
@@ -2,33 +2,31 @@ require 'omniauth/oauth'
2
2
 
3
3
  module OmniAuth
4
4
  module Strategies
5
- #
6
5
  # Authenticate to Tumblr via OAuth and retrieve basic
7
6
  # user information.
8
7
  #
9
8
  # Usage:
10
- #
11
9
  # use OmniAuth::Strategies::Tumblr, 'consumerkey', 'consumersecret'
12
- #
13
10
  class Tumblr < OmniAuth::Strategies::OAuth
14
- # Initialize the middleware
15
- #
16
11
  # @option options [Boolean, true] :sign_in When true, use the "Sign in with Tumblr" flow instead of the authorization flow.
17
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
12
+ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
18
13
  client_options = {
19
- :site => 'http://www.tumblr.com'
14
+ :site => 'http://www.tumblr.com',
20
15
  }
21
-
22
16
  client_options[:authorize_path] = '/oauth/authorize' unless options[:sign_in] == false
23
- super(app, :tumblr, consumer_key, consumer_secret, client_options, options)
17
+ super(app, :tumblr, consumer_key, consumer_secret, client_options, options, &block)
24
18
  end
25
19
 
26
20
  def auth_hash
27
- OmniAuth::Utils.deep_merge(super, {
28
- 'uid' => user['name'],
29
- 'user_info' => user_info,
30
- 'extra' => { 'user_hash' => user }
31
- })
21
+ OmniAuth::Utils.deep_merge(
22
+ super, {
23
+ 'uid' => user['name'],
24
+ 'user_info' => user_info,
25
+ 'extra' => {
26
+ 'user_hash' => user
27
+ },
28
+ }
29
+ )
32
30
  end
33
31
 
34
32
  def user_info
@@ -52,7 +50,7 @@ module OmniAuth
52
50
  end
53
51
 
54
52
  def user_hash
55
- url = "http://www.tumblr.com/api/authenticate"
53
+ url = 'http://www.tumblr.com/api/authenticate'
56
54
  @user_hash ||= Hash.from_xml(@access_token.get(url).body)
57
55
  end
58
56
  end