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
@@ -1,42 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to SmugMug via OAuth and retrieve basic user information.
8
- # Usage:
9
- # use OmniAuth::Strategies::SmugMug, 'consumerkey', 'consumersecret'
10
- #
11
- class SmugMug < OmniAuth::Strategies::OAuth
12
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
13
- super(app, :smugmug, consumer_key, consumer_secret,
14
- {:site => 'http://api.smugmug.com',
15
- :request_token_path => "/services/oauth/getRequestToken.mg",
16
- :access_token_path => "/services/oauth/getAccessToken.mg",
17
- :authorize_path => "/services/oauth/authorize.mg"}, options, &block)
18
- end
19
-
20
- def auth_hash
21
- OmniAuth::Utils.deep_merge(super, {
22
- 'uid' => user_hash['id'],
23
- 'user_info' => user_info,
24
- 'extra' => { 'user_hash' => user_hash }
25
- })
26
- end
27
-
28
- # user info according to schema
29
- def user_info
30
- {
31
- 'nickname' => user_hash['NickName'],
32
- 'name' => user_hash['NickName']
33
- }
34
- end
35
-
36
- # info as supplied by SmugMug
37
- def user_hash
38
- @user_hash ||= MultiJson.decode(@access_token.get('/services/api/json/1.2.2/?method=smugmug.auth.checkAccessToken').body)['Auth']['User']
39
- end
40
- end
41
- end
42
- end
@@ -1,46 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to SoundCloud via OAuth and retrieve basic
8
- # user information.
9
- #
10
- # Usage:
11
- #
12
- # use OmniAuth::Strategies::SoundCloud, 'consumerkey', 'consumersecret'
13
- #
14
-
15
- class SoundCloud < OmniAuth::Strategies::OAuth
16
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
17
- super(app, :soundcloud, consumer_key, consumer_secret, {:site => 'https://api.soundcloud.com'}, options)
18
- end
19
-
20
- def auth_hash
21
- OmniAuth::Utils.deep_merge(super, {
22
- 'uid' => user_hash['id'],
23
- 'user_info' => user_info,
24
- 'extra' => {'user_hash' => user_hash}
25
- })
26
- end
27
-
28
- def user_info
29
- user_hash = self.user_hash
30
-
31
- {
32
- 'name' => user_hash['full_name'],
33
- 'nickname' => user_hash['username'],
34
- 'location' => user_hash['city'],
35
- 'description' => user_hash['description'],
36
- 'image' => user_hash['avatar_url'],
37
- 'urls' => {'Website' => user_hash['website']}
38
- }
39
- end
40
-
41
- def user_hash
42
- @user_hash ||= MultiJson.decode(@access_token.get('/me.json').body)
43
- end
44
- end
45
- end
46
- end
@@ -1,64 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to Tqq via OAuth and retrieve basic
8
- # user information.
9
- #
10
- # Usage:
11
- #
12
- # use OmniAuth::Strategies::Tqq, 'APIKey', 'APIKeySecret'
13
- #
14
- class Tqq < OmniAuth::Strategies::OAuth
15
-
16
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
17
- @api_key = consumer_key
18
-
19
- client_options = {
20
- :site => 'https://open.t.qq.com',
21
- :request_token_path => '/cgi-bin/request_token',
22
- :access_token_path => '/cgi-bin/access_token',
23
- :authorize_path => '/cgi-bin/authorize',
24
- :realm => 'OmniAuth',
25
- :scheme => :query_string,
26
- :nonce => nonce,
27
- :http_method => :get,
28
- }
29
-
30
- super(app, :tqq, consumer_key, consumer_secret, client_options, options, &block)
31
- end
32
-
33
- def nonce
34
- Base64.encode64(OpenSSL::Random.random_bytes(32)).gsub(/\W/, '')[0, 32]
35
- end
36
-
37
- def auth_hash
38
- OmniAuth::Utils.deep_merge(super, {
39
- 'uid' => user_hash["data"]['uid'],
40
- 'user_info' => user_info,
41
- 'extra' => {'user_hash' => user_hash}
42
- })
43
- end
44
-
45
- def user_info
46
- user_hash = self.user_hash
47
- {
48
- 'username' => user_hash["data"]['name'],
49
- 'name' => user_hash["data"]['nick'],
50
- 'location' => user_hash["data"]['location'],
51
- 'image' => user_hash["data"]['head'],
52
- 'description' => user_hash['description'],
53
- 'urls' => {
54
- 'Tqq' => 't.qq.com'
55
- }
56
- }
57
- end
58
-
59
- def user_hash
60
- @user_hash ||= MultiJson.decode(@access_token.get("http://open.t.qq.com/api/user/info?format=json").body)
61
- end
62
- end
63
- end
64
- end
@@ -1,45 +0,0 @@
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
- super(app, :trademe, consumer_key, consumer_secret,
14
- {:site => 'https://secure.trademe.co.nz',
15
- :request_token_path => "/Oauth/RequestToken",
16
- :access_token_path => "/Oauth/AccessToken",
17
- :authorize_path => "/Oauth/Authorize",
18
- }, options, &block)
19
- end
20
-
21
- def auth_hash
22
- OmniAuth::Utils.deep_merge(super, {
23
- 'uid' => user_hash['MemberId'],
24
- 'user_info' => user_info,
25
- 'extra' => { 'user_hash' => user_hash },
26
- })
27
- end
28
-
29
- # user info according to schema
30
- def user_info
31
- {
32
- 'nickname' => user_hash['Nickname'],
33
- 'first_name' => user_hash['FirstName'],
34
- 'last_name' => user_hash['LastName'],
35
- 'name' => [user_hash['FirstName'],user_hash['LastName']].reject{ |n| n.nil? || n.empty? }.join(' '),
36
- }
37
- end
38
-
39
- # info as supplied by TradeMe user summary
40
- def user_hash
41
- @user_hash ||= MultiJson.decode(@access_token.get('https://api.trademe.co.nz/v1/MyTradeMe/Summary.json').body)
42
- end
43
- end
44
- end
45
- end
@@ -1,22 +0,0 @@
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
- super(app, :tripit, consumer_key, consumer_secret,
15
- {:site => 'https://api.tripit.com',
16
- :request_token_path => "/oauth/request_token",
17
- :access_token_path => "/oauth/access_token",
18
- :authorize_url => "https://www.tripit.com/oauth/authorize"}, options, &block)
19
- end
20
- end
21
- end
22
- end
@@ -1,87 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to Vkontakte utilizing OAuth 2.0 and retrieve
8
- # basic user information.
9
- # documentation available here:
10
- # http://vkontakte.ru/developers.php?o=-17680044&p=Authorization&s=0
11
- #
12
- # @example Basic Usage
13
- # use OmniAuth::Strategies::Vkontakte, 'API Key', 'Secret Key'
14
- class Vkontakte < OAuth2
15
- # @param [Rack Application] app standard middleware application parameter
16
- # @param [String] api_key the application id as [registered in Vkontakte]
17
- # @param [String] secret_key the application secret as [registered in Vkontakte]
18
- def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
19
- client_options = {
20
- :site => 'https://vkontakte.ru',
21
- :authorize_url => 'http://api.vkontakte.ru/oauth/authorize',
22
- :access_token_url => 'https://api.vkontakte.ru/oauth/token'
23
- }
24
-
25
- super(app, :vkontakte, api_key, secret_key, client_options, options, &block)
26
- end
27
-
28
- protected
29
-
30
- def user_data
31
- # http://vkontakte.ru/developers.php?o=-17680044&p=Description+of+Fields+of+the+fields+Parameter
32
- @fields ||= ['uid', 'first_name', 'last_name', 'nickname', 'domain', 'sex', 'bdate', 'city', 'country', 'timezone', 'photo', 'photo_big']
33
-
34
- # http://vkontakte.ru/developers.php?o=-1&p=getProfiles
35
- @data ||= MultiJson.decode(@access_token.get("https://api.vkontakte.ru/method/getProfiles?uid=#{@access_token['user_id']}&fields=#{@fields.join(',')}&access_token=#{@access_token.token}"))['response'][0]
36
-
37
- # we need these 2 additional requests since vkontakte returns only ids of the City and Country
38
- # http://vkontakte.ru/developers.php?o=-17680044&p=getCities
39
- cities = MultiJson.decode(@access_token.get("https://api.vkontakte.ru/method/getCities?cids=#{@data['city']}&access_token=#{@access_token.token}"))['response']
40
- @city ||= cities.first['name'] if cities && cities.first
41
-
42
- # http://vkontakte.ru/developers.php?o=-17680044&p=getCountries
43
- countries = MultiJson.decode(@access_token.get("https://api.vkontakte.ru/method/getCountries?cids=#{@data['country']}&access_token=#{@access_token}"))['response']
44
- @country ||= countries.first['name'] if countries && countries.first
45
- end
46
-
47
- def request_phase
48
- options[:response_type] ||= 'code'
49
- super
50
- end
51
-
52
- def user_info
53
- {
54
- 'first_name' => @data['first_name'],
55
- 'last_name' => @data['last_name'],
56
- 'name' => "#{@data['first_name']} #{@data['last_name']}",
57
- 'nickname' => @data['nickname'],
58
- 'birth_date' => @data['bdate'],
59
- 'image' => @data['photo'],
60
- 'location' => "#{@country}, #{@city}",
61
- 'urls' => {
62
- 'Vkontakte' => "http://vkontakte.ru/#{@data['domain']}"
63
- }
64
- }
65
- end
66
-
67
- def user_hash
68
- {
69
- "user_hash" => {
70
- "gender" => @data["sex"],
71
- "timezone" => @data["timezone"],
72
- "photo_big" => @data["photo_big"] # 200px maximum resolution of the avatar (http://vkontakte.ru/developers.php?o=-17680044&p=Description+of+Fields+of+the+fields+Parameter)
73
- }
74
- }
75
- end
76
-
77
- def auth_hash
78
- user_data # process user's info
79
- OmniAuth::Utils.deep_merge(super, {
80
- 'uid' => @data['uid'],
81
- 'user_info' => user_info,
82
- 'extra' => user_hash
83
- })
84
- end
85
- end
86
- end
87
- end
File without changes
@@ -1,77 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe "OmniAuth::Strategies::OAuth" do
4
-
5
- def app
6
- Rack::Builder.new {
7
- use OmniAuth::Test::PhonySession
8
- use OmniAuth::Builder do
9
- provider :oauth, 'example.org', 'abc', 'def', :site => 'https://api.example.org'
10
- provider :oauth, 'example.org_with_authorize_params', 'abc', 'def', { :site => 'https://api.example.org' }, :authorize_params => {:abc => 'def'}
11
- end
12
- run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
13
- }.to_app
14
- end
15
-
16
- def session
17
- last_request.env['rack.session']
18
- end
19
-
20
- before do
21
- stub_request(:post, 'https://api.example.org/oauth/request_token').
22
- to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret&oauth_callback_confirmed=true")
23
- end
24
-
25
- describe '/auth/{name}' do
26
- before do
27
- get '/auth/example.org'
28
- end
29
- it 'should redirect to authorize_url' do
30
- last_response.should be_redirect
31
- last_response.headers['Location'].should == 'https://api.example.org/oauth/authorize?oauth_token=yourtoken'
32
- end
33
-
34
- it 'should redirect to authorize_url with authorize_params when set' do
35
- get '/auth/example.org_with_authorize_params'
36
- last_response.should be_redirect
37
- [
38
- 'https://api.example.org/oauth/authorize?abc=def&oauth_token=yourtoken',
39
- 'https://api.example.org/oauth/authorize?oauth_token=yourtoken&abc=def'
40
- ].should be_include(last_response.headers['Location'])
41
- end
42
-
43
- it 'should set appropriate session variables' do
44
- session['oauth'].should == {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}
45
- end
46
- end
47
-
48
- describe '/auth/{name}/callback' do
49
- before do
50
- stub_request(:post, 'https://api.example.org/oauth/access_token').
51
- to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret")
52
- get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}}
53
- end
54
-
55
- it 'should exchange the request token for an access token' do
56
- last_request.env['omniauth.auth']['provider'].should == 'example.org'
57
- last_request.env['omniauth.auth']['extra']['access_token'].should be_kind_of(OAuth::AccessToken)
58
- end
59
-
60
- it 'should call through to the master app' do
61
- last_response.body.should == 'true'
62
- end
63
-
64
- context "bad gateway (or any 5xx) for access_token" do
65
- before do
66
- stub_request(:post, 'https://api.example.org/oauth/access_token').
67
- to_raise(::Net::HTTPFatalError.new(%Q{502 "Bad Gateway"}, nil))
68
- get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}}
69
- end
70
-
71
- it 'should call fail! with :service_unavailable' do
72
- last_request.env['omniauth.error'].should be_kind_of(::Net::HTTPFatalError)
73
- last_request.env['omniauth.error.type'] = :service_unavailable
74
- end
75
- end
76
- end
77
- end
@@ -1,5 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe OmniAuth::Strategies::SoundCloud do
4
- it_should_behave_like 'an oauth strategy'
5
- end
@@ -1,5 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe OmniAuth::Strategies::TB do
4
- it_should_behave_like "an oauth2 strategy"
5
- end
@@ -1,20 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe OmniAuth::Strategies::Twitter do
4
- it_should_behave_like 'an oauth strategy'
5
-
6
- it 'should use the authenticate (sign in) path by default' do
7
- s = strategy_class.new(app, 'abc', 'def')
8
- s.consumer.options[:authorize_path].should == '/oauth/authenticate'
9
- end
10
-
11
- it 'should set options[:authorize_params] to { :force_login => "true" } if :force_login is true' do
12
- s = strategy_class.new(app, 'abc', 'def', :force_login => true)
13
- s.options[:authorize_params].should == { :force_login => 'true' }
14
- end
15
-
16
- it 'should use the authorize path if :sign_in is false' do
17
- s = strategy_class.new(app, 'abc', 'def', :sign_in => false)
18
- s.consumer.options[:authorize_path].should == '/oauth/authorize'
19
- end
20
- end