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,46 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to Bitly utilizing OAuth 2.0 and retrieve
8
- # basic user information.
9
- #
10
- # @example Basic Usage
11
- # use OmniAuth::Strategies::Bitly, 'API Key', 'Secret Key'
12
- class Bitly < OAuth2
13
- # @param [Rack Application] app standard middleware application parameter
14
- # @param [String] api_key the application id as [registered on Bitly](http://bit.ly/a/account)
15
- # @param [String] secret_key the application secret as [registered on Bitly](http://bit.ly/a/account)
16
- def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
17
- client_options = {
18
- :site => 'https://bit.ly',
19
- :authorize_url => 'https://bit.ly/oauth/authorize',
20
- :access_token_url => 'https://api-ssl.bit.ly/oauth/access_token'
21
- }
22
-
23
- super(app, :bitly, api_key, secret_key, client_options, options, &block)
24
- end
25
-
26
- protected
27
-
28
- def user_data
29
- {
30
- 'login' => @access_token['login'],
31
- 'api_key' => @access_token['apiKey']
32
- }
33
- end
34
-
35
- def auth_hash
36
- OmniAuth::Utils.deep_merge(super, {
37
- 'uid' => @access_token['login'],
38
- 'user_info' => user_data,
39
- 'extra' => {'user_hash' => user_data}
40
- })
41
- end
42
- end
43
-
44
- end
45
-
46
- end
@@ -1,72 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to Gowalla utilizing OAuth 2.0 and retrieve
8
- # basic user information.
9
- #
10
- # @example Basic Usage
11
- # use OmniAuth::Strategies::Gowalla, 'API Key', 'Secret Key'
12
- class Gowalla < OAuth2
13
- # @param [Rack Application] app standard middleware application parameter
14
- # @param [String] api_key the application id as [registered on Gowalla](http://gowalla.com/api/keys)
15
- # @param [String] secret_key the application secret as [registered on Gowalla](http://gowalla.com/api/keys)
16
- # @option options ['read','read-write'] :scope ('read') the scope of your authorization request; must be `read` or `read-write`
17
- def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
18
- client_options = {
19
- :site => 'https://api.gowalla.com/api/oauth',
20
- :authorize_url => 'https://gowalla.com/api/oauth/new',
21
- :access_token_url => 'https://api.gowalla.com/api/oauth/token'
22
- }
23
-
24
- super(app, :gowalla, api_key, secret_key, client_options, options, &block)
25
- end
26
-
27
- protected
28
-
29
- def user_data
30
- @data ||= MultiJson.decode(@access_token.get("/users/me.json"))
31
- end
32
-
33
- def refresh_token
34
- @refresh_token ||= @access_token.refresh_token
35
- end
36
-
37
- def token_expires_at
38
- @expires_at ||= @access_token.expires_at
39
- end
40
-
41
- def request_phase
42
- options[:scope] ||= "read"
43
- super
44
- end
45
-
46
- def user_info
47
- {
48
- 'name' => "#{user_data['first_name']} #{user_data['last_name']}",
49
- 'nickname' => user_data["username"],
50
- 'first_name' => user_data["first_name"],
51
- 'last_name' => user_data["last_name"],
52
- 'location' => user_data["hometown"],
53
- 'description' => user_data["bio"],
54
- 'image' => user_data["image_url"],
55
- 'phone' => nil,
56
- 'urls' => {
57
- 'Gowalla' => "http://www.gowalla.com#{user_data['url']}",
58
- 'Website' => user_data["website"]
59
- }
60
- }
61
- end
62
-
63
- def auth_hash
64
- OmniAuth::Utils.deep_merge(super, {
65
- 'uid' => user_data["url"].split('/').last,
66
- 'user_info' => user_info,
67
- 'extra' => {'user_hash' => user_data, 'refresh_token' => refresh_token, 'token_expires_at' => token_expires_at}
68
- })
69
- end
70
- end
71
- end
72
- end
@@ -1,67 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
-
5
- module OmniAuth
6
- module Strategies
7
- class Hyves < OmniAuth::Strategies::OAuth
8
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
9
- client_options = {
10
- :request_token_path => request_token_path,
11
- :authorize_path => "http://www.hyves.nl/api/authorize",
12
- :access_token_path => access_token_path,
13
- :http_method => :get,
14
- :scheme => :header
15
- }
16
- super(app, :hyves, consumer_key, consumer_secret, client_options, options, &block)
17
- end
18
-
19
- def auth_hash
20
- hash = user_hash(@access_token)
21
-
22
- {
23
- "provider" => "hyves",
24
- "uid" => hash["userid"],
25
- "user_info" => {
26
- "name" => hash["firstname"] + " " + hash["lastname"],
27
- "first_name" => hash["firstname"],
28
- "last_name" => hash["lastname"]
29
- },
30
- "credentials" => {
31
- "token" => @access_token.token,
32
- "secret" => @access_token.secret
33
- }
34
- }
35
- end
36
-
37
- def user_hash(access_token)
38
- rsp = MultiJson.decode( access_token.get("http://data.hyves-api.nl/?userid=#{access_token.params[:userid]}&ha_method=users.get&#{default_options}").body )
39
- rsp["user"].first
40
- end
41
-
42
- def request_token_path
43
- "http://data.hyves-api.nl/?#{request_token_options}&#{default_options}"
44
- end
45
-
46
- def access_token_path
47
- "http://data.hyves-api.nl/?#{access_token_options}&#{default_options}"
48
- end
49
-
50
- def default_options
51
- to_params( { :ha_version => "2.0", :ha_format => "json", :ha_fancylayout => false } )
52
- end
53
-
54
- def request_token_options
55
- to_params( { :methods => "users.get,friends.get,wwws.create", :ha_method => "auth.requesttoken", :strict_oauth_spec_response => true } )
56
- end
57
-
58
- def access_token_options
59
- to_params( { :ha_method => "auth.accesstoken", :strict_oauth_spec_response => true } )
60
- end
61
-
62
- def to_params(options)
63
- options.collect { |key, value| "#{key}=#{value}"}.join('&')
64
- end
65
- end
66
- end
67
- end
@@ -1,107 +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://api.mail.ru/docs/guides/oauth/sites/
11
- #
12
- # @example Basic Usage
13
- # use OmniAuth::Strategies::Mailru, 'API Key', 'Secret Key', :private_key => 'Private Key'
14
- class Mailru < OAuth2
15
- # @param [Rack Application] app standard middleware application parameter
16
- # @param [String] api_key the application id as [registered in Mailru]
17
- # @param [String] secret_key the application secret as [registered in Mailru]
18
- def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
19
- client_options = {
20
- :site => 'https://connect.mail.ru',
21
- :authorize_path => '/oauth/authorize',
22
- :access_token_path => '/oauth/token'
23
- }
24
-
25
- @private_key = options[:private_key]
26
-
27
- super(app, :mailru, api_key, secret_key, client_options, options, &block)
28
- end
29
-
30
- protected
31
-
32
- def request_phase
33
- options[:response_type] ||= 'code'
34
- super
35
- end
36
-
37
- def calculate_signature(params)
38
- str = params['uids'] + (params.sort.collect { |c| "#{c[0]}=#{c[1]}" }).join('') + @private_key
39
- Digest::MD5.hexdigest(str)
40
- end
41
-
42
- def user_data
43
- request_params = {
44
- 'method' => 'users.getInfo',
45
- 'app_id' => client_id,
46
- 'session_key' => @access_token.token,
47
- 'uids' => @access_token['x_mailru_vid']
48
- }
49
-
50
- request_params.merge!('sig' => calculate_signature(request_params))
51
- @data ||= MultiJson.decode(client.request(:get, 'http://www.appsmail.ru/platform/api', request_params))[0]
52
- end
53
-
54
- #"uid": "15410773191172635989",
55
- #"first_name": "Евгений",
56
- #"last_name": "Маслов",
57
- #"nick": "maslov",
58
- #"sex": 0,
59
- #"birthday": "15.02.1980",
60
- #"has_pic": 1,
61
- #"pic": "http://avt.appsmail.ru/mail/emaslov/_avatar",
62
- #"pic_small": "http://avt.appsmail.ru/mail/emaslov/_avatarsmall",
63
- #"pic_big": "http://avt.appsmail.ru/mail/emaslov/_avatarbig",
64
- #"link": "http://my.mail.ru/mail/emaslov/",
65
- #"referer_type": "",
66
- #"referer_id": "",
67
- #"is_online": 1,
68
- #"vip" : 1,
69
- #"location": {
70
- # "country": {
71
- # "name": "Россия",
72
- # "id": "24"
73
- # },
74
- # "city": {
75
- # "name": "Москва",
76
- # "id": "25"
77
- # },
78
- # "region": {
79
- # "name": "Москва",
80
- # "id": "999999"
81
- # }
82
- #}
83
-
84
- def user_info
85
- {
86
- 'nickname' => user_data['nick'],
87
- 'email' => user_data['email'],
88
- 'first_name' => user_data["first_name"],
89
- 'last_name' => user_data["last_name"],
90
- 'name' => "#{user_data['first_name']} #{user_data['last_name']}",
91
- 'image' => @data['pic'],
92
- 'urls' => {
93
- 'Mailru' => user_data["link"]
94
- }
95
- }
96
- end
97
-
98
- def auth_hash
99
- OmniAuth::Utils.deep_merge(super, {
100
- 'uid' => user_data['uid'],
101
- 'user_info' => user_info,
102
- 'extra' => {'user_hash' => user_data}
103
- })
104
- end
105
- end
106
- end
107
- end
@@ -1,58 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to Plurk via OAuth and retrieve basic user info.
8
- #
9
- # Please note that this strategy relies on Plurk API 2.0,
10
- # which is still in Beta.
11
- #
12
- # Usage:
13
- # use OmniAuth::Strategies::Plurk
14
- class Plurk < OmniAuth::Strategies::OAuth
15
-
16
- # @param [Rack Application] app standard middleware application parameter
17
- # @param [String] client_key App key [registered on plurk] (http://www.plurk.com/PlurkApp/register)
18
- # @param [String] client_secret App secret registered on plurk
19
- def initialize(app, client_key = nil, client_secret = nil, options = {}, &block)
20
- client_options = { :site => 'http://www.plurk.com',
21
- :request_token_path => '/OAuth/request_token',
22
- :access_token_path => '/OAuth/access_token',
23
- :authorize_path => '/OAuth/authorize' }
24
-
25
- super(app, :plurk, client_key, client_secret, client_options, options)
26
- end
27
-
28
- def auth_hash
29
- user = self.user_hash
30
- OmniAuth::Utils.deep_merge(super, {
31
- 'uid' => user['id'],
32
- 'user_info' => user_info,
33
- 'extra' => {'user_hash' => user_hash}
34
- })
35
- end
36
-
37
- def user_info
38
- user = self.user_hash
39
- {
40
- 'name' => user['full_name'],
41
- 'nickname' => user['display_name'] || user['nick_name'],
42
- 'location' => user['location'],
43
- 'image' => if user['has_profile_image'] == 1
44
- "http://avatars.plurk.com/#{user['id']}-medium#{user['avatar']}.gif"
45
- else
46
- "http://www.plurk.com/static/default_medium.gif"
47
- end,
48
- 'urls' => { 'Plurk' => 'http://plurk.com/' + user['nick_name']}
49
- }
50
- end
51
-
52
- def user_hash
53
- @user_hash ||= MultiJson.decode(@access_token.get('/APP/Profile/getOwnProfile').body)['user_info']
54
- end
55
-
56
- end
57
- end
58
- end
@@ -1,45 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to Rdio via OAuth and retrieve basic user information.
8
- # Usage:
9
- # use OmniAuth::Strategies::Rdio, 'consumerkey', 'consumersecret'
10
- #
11
- class Rdio < OmniAuth::Strategies::OAuth
12
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
13
- opts = {
14
- :site => 'http://api.rdio.com',
15
- :request_token_path => "/oauth/request_token",
16
- :access_token_path => "/oauth/access_token",
17
- :authorize_url => "https://www.rdio.com/oauth/authorize"
18
- }
19
- super(app, :rdio, consumer_key, consumer_secret, opts, options, &block)
20
- end
21
-
22
- def auth_hash
23
- OmniAuth::Utils.deep_merge(super, {
24
- 'uid' => user_hash['key'],
25
- 'user_info' => user_info,
26
- 'extra' => { 'user_hash' => user_hash }
27
- })
28
- end
29
-
30
- def user_info
31
- user = user_hash
32
- {
33
- 'nickname' => user['username'],
34
- 'first_name' => user['firstName'],
35
- 'last_name' => user['lastName'],
36
- 'name' => "#{user['firstName']} #{user['lastName']}"
37
- }
38
- end
39
-
40
- def user_hash
41
- @user_hash ||= MultiJson.decode(@access_token.post("http://api.rdio.com/1/", { :method => 'currentUser', :extras => 'username' }).body)['result']
42
- end
43
- end
44
- end
45
- end
@@ -1,44 +0,0 @@
1
- require 'omniauth/strategies/oauth2'
2
-
3
- module OmniAuth
4
- module Strategies
5
- class Salesforce < OmniAuth::Strategies::OAuth2
6
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
7
- client_options = {
8
- :site => 'https://login.salesforce.com',
9
- :authorize_path => '/services/oauth2/authorize',
10
- :access_token_path => '/services/oauth2/token'
11
- }
12
-
13
- options.merge!(:response_type => 'code', :grant_type => 'authorization_code')
14
-
15
- super(app, :salesforce, consumer_key, consumer_secret, client_options, options, &block)
16
- end
17
-
18
- def auth_hash
19
- data = user_data
20
- OmniAuth::Utils.deep_merge(super, {
21
- 'uid' => @access_token['id'],
22
- 'credentials' => {
23
- 'instance_url' => @access_token['instance_url']
24
- },
25
- 'extra' => {'user_hash' => data},
26
- 'user_info' => {
27
- 'email' => data['email'],
28
- 'name' => data['display_name']
29
- }
30
- })
31
- end
32
-
33
- def user_data
34
- @data ||= MultiJson.decode(@access_token.get(@access_token['id']))
35
- rescue ::OAuth2::HTTPError => e
36
- if e.response.status == 302
37
- @data ||= MultiJson.decode(@access_token.get(e.response.headers['location']))
38
- else
39
- raise e
40
- end
41
- end
42
- end
43
- end
44
- end