oa-oauth 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. data/lib/omniauth/oauth.rb +33 -24
  2. data/lib/omniauth/strategies/bitly.rb +4 -4
  3. data/lib/omniauth/strategies/doit.rb +8 -8
  4. data/lib/omniauth/strategies/dopplr.rb +6 -6
  5. data/lib/omniauth/strategies/douban.rb +60 -0
  6. data/lib/omniauth/strategies/evernote.rb +1 -6
  7. data/lib/omniauth/strategies/facebook.rb +5 -5
  8. data/lib/omniauth/strategies/foursquare.rb +12 -7
  9. data/lib/omniauth/strategies/github.rb +6 -6
  10. data/lib/omniauth/strategies/goodreads.rb +3 -3
  11. data/lib/omniauth/strategies/gowalla.rb +6 -6
  12. data/lib/omniauth/strategies/hyves.rb +14 -14
  13. data/lib/omniauth/strategies/instagram.rb +7 -7
  14. data/lib/omniauth/strategies/instapaper.rb +6 -6
  15. data/lib/omniauth/strategies/linked_in.rb +9 -9
  16. data/lib/omniauth/strategies/miso.rb +5 -5
  17. data/lib/omniauth/strategies/mixi.rb +8 -8
  18. data/lib/omniauth/strategies/oauth2.rb +21 -22
  19. data/lib/omniauth/strategies/qzone.rb +69 -0
  20. data/lib/omniauth/strategies/rdio.rb +45 -0
  21. data/lib/omniauth/strategies/renren.rb +87 -0
  22. data/lib/omniauth/strategies/salesforce.rb +1 -1
  23. data/lib/omniauth/strategies/smug_mug.rb +4 -4
  24. data/lib/omniauth/strategies/sound_cloud.rb +7 -7
  25. data/lib/omniauth/strategies/t163.rb +57 -0
  26. data/lib/omniauth/strategies/thirty_seven_signals.rb +5 -5
  27. data/lib/omniauth/strategies/tqq.rb +64 -0
  28. data/lib/omniauth/strategies/trade_me.rb +4 -4
  29. data/lib/omniauth/strategies/tsina.rb +79 -0
  30. data/lib/omniauth/strategies/tsohu.rb +57 -0
  31. data/lib/omniauth/strategies/twitter.rb +7 -7
  32. data/lib/omniauth/strategies/type_pad.rb +6 -6
  33. data/lib/omniauth/strategies/vkontakte.rb +1 -1
  34. data/lib/omniauth/strategies/xauth.rb +9 -9
  35. data/lib/omniauth/strategies/yahoo.rb +4 -4
  36. data/lib/omniauth/strategies/yammer.rb +43 -0
  37. data/lib/omniauth/version.rb +19 -0
  38. data/oa-oauth.gemspec +13 -10
  39. data/spec/omniauth/strategies/bitly_spec.rb +1 -1
  40. data/spec/omniauth/strategies/dailymile_spec.rb +1 -1
  41. data/spec/omniauth/strategies/doit_spec.rb +2 -2
  42. data/spec/omniauth/strategies/dopplr_spec.rb +1 -1
  43. data/spec/omniauth/strategies/douban_spec.rb +5 -0
  44. data/spec/omniauth/strategies/evernote_spec.rb +3 -5
  45. data/spec/omniauth/strategies/facebook_spec.rb +2 -2
  46. data/spec/omniauth/strategies/foursquare_spec.rb +15 -1
  47. data/spec/omniauth/strategies/github_spec.rb +1 -1
  48. data/spec/omniauth/strategies/goodreads_spec.rb +1 -1
  49. data/spec/omniauth/strategies/google_spec.rb +1 -1
  50. data/spec/omniauth/strategies/gowalla_spec.rb +3 -3
  51. data/spec/omniauth/strategies/hyves_spec.rb +2 -2
  52. data/spec/omniauth/strategies/identica_spec.rb +1 -1
  53. data/spec/omniauth/strategies/linked_in_spec.rb +1 -1
  54. data/spec/omniauth/strategies/meetup_spec.rb +1 -1
  55. data/spec/omniauth/strategies/miso_spec.rb +2 -2
  56. data/spec/omniauth/strategies/netflix_spec.rb +1 -1
  57. data/spec/omniauth/strategies/oauth_spec.rb +1 -1
  58. data/spec/omniauth/strategies/rdio_spec.rb +5 -0
  59. data/spec/omniauth/strategies/salesforce_spec.rb +1 -1
  60. data/spec/omniauth/strategies/smug_mug_spec.rb +3 -3
  61. data/spec/omniauth/strategies/sound_cloud_spec.rb +2 -2
  62. data/spec/omniauth/strategies/t163_spec.rb +5 -0
  63. data/spec/omniauth/strategies/teambox_spec.rb +1 -1
  64. data/spec/omniauth/strategies/thirty_seven_signals_spec.rb +2 -2
  65. data/spec/omniauth/strategies/trade_me_spec.rb +2 -2
  66. data/spec/omniauth/strategies/trip_it_spec.rb +1 -1
  67. data/spec/omniauth/strategies/tsina_spec.rb +5 -0
  68. data/spec/omniauth/strategies/tumblr_spec.rb +2 -2
  69. data/spec/omniauth/strategies/twitter_spec.rb +4 -4
  70. data/spec/omniauth/strategies/type_pad_spec.rb +1 -1
  71. data/spec/omniauth/strategies/vimeo_spec.rb +2 -2
  72. data/spec/omniauth/strategies/vkontakte_spec.rb +1 -1
  73. data/spec/omniauth/strategies/yahoo_spec.rb +1 -1
  74. data/spec/omniauth/strategies/yammer_spec.rb +5 -0
  75. data/spec/omniauth/strategies/you_tube_spec.rb +1 -1
  76. data/spec/spec_helper.rb +4 -9
  77. data/spec/support/shared_examples.rb +3 -3
  78. metadata +77 -25
  79. data/Gemfile +0 -3
@@ -3,7 +3,7 @@ require 'multi_json'
3
3
 
4
4
  module OmniAuth
5
5
  module Strategies
6
- #
6
+ #
7
7
  # Authenticate to Twitter via OAuth and retrieve basic
8
8
  # user information.
9
9
  #
@@ -19,12 +19,12 @@ module OmniAuth
19
19
  client_options = {
20
20
  :site => 'https://api.twitter.com'
21
21
  }
22
-
22
+
23
23
  options[:authorize_params] = {:force_login => 'true'} if options.delete(:force_login) == true
24
24
  client_options[:authorize_path] = '/oauth/authenticate' unless options[:sign_in] == false
25
25
  super(app, :twitter, consumer_key, consumer_secret, client_options, options)
26
26
  end
27
-
27
+
28
28
  def auth_hash
29
29
  OmniAuth::Utils.deep_merge(super, {
30
30
  'uid' => @access_token.params[:user_id],
@@ -32,13 +32,13 @@ module OmniAuth
32
32
  'extra' => {'user_hash' => user_hash}
33
33
  })
34
34
  end
35
-
35
+
36
36
  def user_info
37
37
  user_hash = self.user_hash
38
-
38
+
39
39
  {
40
40
  'nickname' => user_hash['screen_name'],
41
- 'name' => user_hash['name'],
41
+ 'name' => user_hash['name'] || user_hash['screen_name'],
42
42
  'location' => user_hash['location'],
43
43
  'image' => user_hash['profile_image_url'],
44
44
  'description' => user_hash['description'],
@@ -48,7 +48,7 @@ module OmniAuth
48
48
  }
49
49
  }
50
50
  end
51
-
51
+
52
52
  def user_hash
53
53
  @user_hash ||= MultiJson.decode(@access_token.get('/1/account/verify_credentials.json').body)
54
54
  end
@@ -3,7 +3,7 @@ require 'multi_json'
3
3
 
4
4
  module OmniAuth
5
5
  module Strategies
6
- #
6
+ #
7
7
  # Authenticate to Typepad via OAuth and retrieve basic
8
8
  # user information.
9
9
  #
@@ -33,7 +33,7 @@ module OmniAuth
33
33
 
34
34
  super(app, :type_pad, consumer_key, consumer_secret, client_options, options)
35
35
  end
36
-
36
+
37
37
  def auth_hash
38
38
  ui = user_info
39
39
  OmniAuth::Utils.deep_merge(super, {
@@ -42,10 +42,10 @@ module OmniAuth
42
42
  'extra' => {'user_hash' => user_hash}
43
43
  })
44
44
  end
45
-
45
+
46
46
  def user_info
47
47
  user_hash = self.user_hash
48
-
48
+
49
49
  {
50
50
  'uid' => user_hash['urlId'],
51
51
  'nickname' => user_hash['preferredUsername'],
@@ -55,12 +55,12 @@ module OmniAuth
55
55
  'urls' => {'Profile' => user_hash['profilePageUrl']}
56
56
  }
57
57
  end
58
-
58
+
59
59
  def user_hash
60
60
  # For authenticated requests, you have to use header as your scheme.
61
61
  # Failure to do so gives a unique response body - 'Auth is required'.
62
62
  # 'Unauthorized' is the response body of a truly unauthorized request.
63
-
63
+
64
64
  # Also note that API requests hit a different site than the OAuth dance.
65
65
  r = self.consumer.request(
66
66
  :get,
@@ -6,7 +6,7 @@ module OmniAuth
6
6
  #
7
7
  # Authenticate to Vkontakte utilizing OAuth 2.0 and retrieve
8
8
  # basic user information.
9
- # documentation available here:
9
+ # documentation available here:
10
10
  # http://vkontakte.ru/developers.php?o=-17680044&p=Authorization&s=0
11
11
  #
12
12
  # @example Basic Usage
@@ -5,17 +5,17 @@ module OmniAuth
5
5
  module Strategies
6
6
  class XAuth
7
7
  include OmniAuth::Strategy
8
-
8
+
9
9
  attr_reader :name
10
10
  attr_accessor :consumer_key, :consumer_secret, :consumer_options
11
-
11
+
12
12
  def initialize(app, name, consumer_key = nil, consumer_secret = nil, consumer_options = {}, options = {}, &block)
13
13
  self.consumer_key = consumer_key
14
14
  self.consumer_secret = consumer_secret
15
15
  self.consumer_options = consumer_options
16
16
  super
17
17
  end
18
-
18
+
19
19
  def request_phase
20
20
  session['oauth'] ||= {}
21
21
  if env['REQUEST_METHOD'] == 'GET'
@@ -25,18 +25,18 @@ module OmniAuth
25
25
  redirect callback_path
26
26
  end
27
27
  end
28
-
28
+
29
29
  def get_credentials
30
30
  OmniAuth::Form.build(consumer_options[:title] || "xAuth Credentials") do
31
31
  text_field 'Username', 'username'
32
32
  password_field 'Password', 'password'
33
33
  end.to_response
34
34
  end
35
-
35
+
36
36
  def consumer
37
37
  ::OAuth::Consumer.new(consumer_key, consumer_secret, consumer_options.merge(options[:client_options] || options[:consumer_options] || {}))
38
38
  end
39
-
39
+
40
40
  def callback_phase
41
41
  @access_token = consumer.get_access_token(nil, {}, session['omniauth.xauth'])
42
42
  super
@@ -47,9 +47,9 @@ module OmniAuth
47
47
  rescue ::MultiJson::DecodeError => e
48
48
  fail!(:invalid_response, e)
49
49
  ensure
50
- session['omniauth.xauth'] = nil
50
+ session['omniauth.xauth'] = nil
51
51
  end
52
-
52
+
53
53
  def auth_hash
54
54
  OmniAuth::Utils.deep_merge(super, {
55
55
  'credentials' => {
@@ -60,7 +60,7 @@ module OmniAuth
60
60
  }
61
61
  })
62
62
  end
63
-
63
+
64
64
  end
65
65
  end
66
66
  end
@@ -3,7 +3,7 @@ require 'multi_json'
3
3
 
4
4
  module OmniAuth
5
5
  module Strategies
6
- #
6
+ #
7
7
  # Authenticate to Yahoo via OAuth and retrieve basic
8
8
  # user information.
9
9
  #
@@ -22,7 +22,7 @@ module OmniAuth
22
22
 
23
23
  super(app, :yahoo, consumer_key, consumer_secret, client_options, options)
24
24
  end
25
-
25
+
26
26
  def auth_hash
27
27
  ui = user_info
28
28
  OmniAuth::Utils.deep_merge(super, {
@@ -31,7 +31,7 @@ module OmniAuth
31
31
  'extra' => {'user_hash' => user_hash}
32
32
  })
33
33
  end
34
-
34
+
35
35
  def user_info
36
36
  user_hash = self.user_hash
37
37
  profile = user_hash['profile']
@@ -45,7 +45,7 @@ module OmniAuth
45
45
  'urls' => {'Profile' => profile['profileUrl'] }
46
46
  }
47
47
  end
48
-
48
+
49
49
  def user_hash
50
50
  uid = @access_token.params['xoauth_yahoo_guid']
51
51
  @user_hash ||= MultiJson.decode(@access_token.get("http://social.yahooapis.com/v1/user/#{uid}/profile?format=json").body)
@@ -0,0 +1,43 @@
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Yammer < OmniAuth::Strategies::OAuth
7
+ def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
8
+ client_options = {
9
+ :site => 'https://www.yammer.com',
10
+ :request_token_path => '/oauth/request_token',
11
+ :access_token_path => '/oauth/access_token',
12
+ :authorize_path => "/oauth/authorize"
13
+ }
14
+
15
+ super(app, :yammer, consumer_key, consumer_secret, client_options, options)
16
+ end
17
+
18
+ def auth_hash
19
+ OmniAuth::Utils.deep_merge(super, {
20
+ 'uid' => user_hash['id'],
21
+ 'user_info' => user_info,
22
+ 'extra' => {'user_hash' => user_hash}
23
+ })
24
+ end
25
+
26
+ def user_info
27
+ user_hash = self.user_hash
28
+ {
29
+ 'nickname' => user_hash['name'],
30
+ 'name' => user_hash['full-name'],
31
+ 'location' => user_hash['location'],
32
+ 'image' => user_hash['mugshot-url'],
33
+ 'description' => user_hash['job-title'],
34
+ 'urls' => {'Yammer' => user_hash['web-url']}
35
+ }
36
+ end
37
+
38
+ def user_hash
39
+ @user_hash ||= MultiJson.decode(@access_token.get('/api/v1/users/current.json').body)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,19 @@
1
+ module OmniAuth
2
+ module Version
3
+ unless defined?(::OmniAuth::Version::MAJOR)
4
+ MAJOR = 0
5
+ end
6
+ unless defined?(::OmniAuth::Version::MINOR)
7
+ MINOR = 2
8
+ end
9
+ unless defined?(::OmniAuth::Version::PATCH)
10
+ PATCH = 5
11
+ end
12
+ unless defined?(::OmniAuth::Version::PRE)
13
+ PRE = nil
14
+ end
15
+ unless defined?(::OmniAuth::Version::STRING)
16
+ STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
17
+ end
18
+ end
19
+ end
@@ -1,23 +1,27 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../../omniauth/lib/omniauth/version', __FILE__)
2
+ require File.expand_path('../lib/omniauth/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.add_dependency 'oa-core', Omniauth::VERSION.dup
6
- gem.add_dependency 'multi_json', '>= 0.0.5'
7
- gem.add_dependency 'nokogiri', '~> 1.4.2'
8
- gem.add_dependency 'oauth', '~> 0.4.0'
9
- gem.add_dependency 'faraday', '~> 0.6.1'
10
- gem.add_dependency 'oauth2', '~> 0.4.1'
5
+ gem.add_runtime_dependency 'faraday', '~> 0.6.1'
6
+ gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java'
7
+ gem.add_runtime_dependency 'multi_json', '~> 1.0.0'
8
+ gem.add_runtime_dependency 'multi_xml', '~> 0.2.2'
9
+ gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
10
+ gem.add_runtime_dependency 'oauth', '~> 0.4.0'
11
+ gem.add_runtime_dependency 'oauth2', '~> 0.4.1'
11
12
  gem.add_development_dependency 'evernote', '~> 0.9'
13
+ gem.add_development_dependency 'maruku', '~> 0.6'
12
14
  gem.add_development_dependency 'rack-test', '~> 0.5'
13
15
  gem.add_development_dependency 'rake', '~> 0.8'
14
16
  gem.add_development_dependency 'rspec', '~> 2.5'
17
+ gem.add_development_dependency 'simplecov', '~> 0.4'
15
18
  gem.add_development_dependency 'webmock', '~> 1.6'
16
19
  gem.add_development_dependency 'yard', '~> 0.6'
20
+ gem.add_development_dependency 'ZenTest', '~> 4.5'
17
21
  gem.name = 'oa-oauth'
18
- gem.version = Omniauth::VERSION.dup
19
- gem.summary = %q{OAuth strategies for OmniAuth.}
22
+ gem.version = OmniAuth::Version::STRING
20
23
  gem.description = %q{OAuth strategies for OmniAuth.}
24
+ gem.summary = gem.description
21
25
  gem.email = ['michael@intridea.com', 'sferik@gmail.com']
22
26
  gem.homepage = 'http://github.com/intridea/omniauth'
23
27
  gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
@@ -26,5 +30,4 @@ Gem::Specification.new do |gem|
26
30
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
31
  gem.require_paths = ['lib']
28
32
  gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
29
-
30
33
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Bitly do
4
4
  it_should_behave_like "an oauth2 strategy"
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Dailymile do
4
4
  it_should_behave_like "an oauth2 strategy"
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Doit do
4
4
  it_should_behave_like "an oauth2 strategy"
5
- end
5
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Dopplr do
4
4
  it_should_behave_like "an oauth strategy"
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe OmniAuth::Strategies::Douban do
4
+ it_should_behave_like 'an oauth strategy'
5
+ end
@@ -1,7 +1,5 @@
1
- unless defined?(JRUBY_VERSION)
2
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
3
2
 
4
- describe OmniAuth::Strategies::Evernote do
5
- it_should_behave_like "an oauth strategy"
6
- end
3
+ describe OmniAuth::Strategies::Evernote do
4
+ it_should_behave_like "an oauth strategy"
7
5
  end
@@ -1,5 +1,5 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Facebook do
4
4
  it_should_behave_like "an oauth2 strategy"
5
- end
5
+ end
@@ -1,4 +1,18 @@
1
- require 'spec_helper'
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Foursquare do
4
+ it_should_behave_like "an oauth2 strategy"
5
+ subject{ OmniAuth::Strategies::Foursquare.new(lambda{|env|[200,{},[""]]} , 'abc', 'def')}
6
+
7
+ it 'should use the mobile authorize url when :mobile is true' do
8
+ subject.authorize_url(:mobile => true).should be_include("/mobile/")
9
+ end
10
+
11
+ it 'should use the authorize endpoint if :sign_in is false' do
12
+ subject.authorize_url(:sign_in => false).should be_include("/authorize")
13
+ end
14
+
15
+ it 'should default to the authenticate endpoint' do
16
+ subject.client.authorize_url.should be_include('/authenticate')
17
+ end
4
18
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::GitHub do
4
4
  it_should_behave_like "an oauth2 strategy"
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Goodreads do
4
4
  it_should_behave_like 'an oauth strategy'
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Google do
4
4
  it_should_behave_like 'an oauth strategy'
@@ -1,5 +1,5 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Gowalla do
4
- it_should_behave_like "an oauth2 strategy"
5
- end
4
+ it_should_behave_like "an oauth2 strategy"
5
+ end
@@ -1,5 +1,5 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Hyves do
4
4
  it_should_behave_like "an oauth strategy"
5
- end
5
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Identica do
4
4
  it_should_behave_like 'an oauth strategy'
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::LinkedIn do
4
4
  it_should_behave_like "an oauth strategy"
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::Meetup do
4
4
  it_should_behave_like 'an oauth strategy'