oa-oauth 0.3.0.rc3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,7 +36,6 @@ module OmniAuth
36
36
  autoload :TypePad, 'omniauth/strategies/oauth/type_pad'
37
37
  autoload :Vimeo, 'omniauth/strategies/oauth/vimeo'
38
38
  autoload :Yahoo, 'omniauth/strategies/oauth/yahoo'
39
- autoload :Yammer, 'omniauth/strategies/oauth/yammer'
40
39
  autoload :YouTube, 'omniauth/strategies/oauth/you_tube'
41
40
 
42
41
  autoload :OAuth2, 'omniauth/strategies/oauth2'
@@ -65,6 +64,7 @@ module OmniAuth
65
64
  autoload :Viadeo, 'omniauth/strategies/oauth2/viadeo'
66
65
  autoload :Vkontakte, 'omniauth/strategies/oauth2/vkontakte'
67
66
  autoload :WePay, 'omniauth/strategies/oauth2/we_pay'
67
+ autoload :Yammer, 'omniauth/strategies/oauth2/yammer'
68
68
 
69
69
 
70
70
  autoload :XAuth, 'omniauth/strategies/xauth'
@@ -22,7 +22,7 @@ module OmniAuth
22
22
  def request_phase
23
23
  google_email_scope = "www.googleapis.com/auth/userinfo.email"
24
24
  options[:scope] ||= "https://#{google_email_scope}"
25
- options[:scope] << "https://#{google_email_scope}" unless options[:scope] =~ %r[http[s]?:\/\/#{google_email_scope}]
25
+ options[:scope] << " https://#{google_email_scope}" unless options[:scope] =~ %r[http[s]?:\/\/#{google_email_scope}]
26
26
  redirect client.auth_code.authorize_url(
27
27
  {:redirect_uri => callback_url, :response_type => "code"}.merge(options))
28
28
  end
@@ -24,19 +24,19 @@ module OmniAuth
24
24
  end
25
25
 
26
26
  def user_info(access_token)
27
- authenticated_user = MultiXml.parse(@access_token.get('/api/auth_user').body)
28
- id = authenticated_user.xpath('GoodreadsResponse/user').attribute('id').value.to_i
29
- response_doc = MultiXml.parse(open("http://www.goodreads.com/user/show/#{id}.xml?key=#{@consumer_key}").read)
30
- user = response_doc.xpath('GoodreadsResponse/user')
27
+ authenticated_user = MultiXml.parse(access_token.get('/api/auth_user').body)
28
+ id = authenticated_user['GoodreadsResponse']['user']['id'].to_i
29
+ response_doc = MultiXml.parse(access_token.get("/user/show/#{id}.xml?key=#{@consumer_key}").body)
30
+ user = response_doc['GoodreadsResponse']['user']
31
31
 
32
32
  hash = {
33
33
  'id' => id,
34
- 'name' => user.xpath('name').text,
35
- 'user_name' => user.xpath('user_name').text,
36
- 'image_url' => user.xpath('image_url').text,
37
- 'about' => user.xpath('about').text,
38
- 'location' => user.xpath('location').text,
39
- 'website' => user.xpath('website').text,
34
+ 'name' => user['name'],
35
+ 'user_name' => user['user_name'],
36
+ 'image_url' => user['image_url'],
37
+ 'about' => user['about'],
38
+ 'location' => user['location'],
39
+ 'website' => user['website'],
40
40
  }
41
41
  end
42
42
  end
@@ -17,7 +17,7 @@ module OmniAuth
17
17
  :site => 'https://api.twitter.com',
18
18
  }
19
19
  options[:authorize_params] = {:force_login => 'true'} if options.delete(:force_login) == true
20
- client_options[:authorize_path] = '/oauth/authorize' unless options[:sign_in] == false
20
+ client_options[:authorize_path] = '/oauth/authenticate' unless options[:sign_in] == false
21
21
  super(app, options[:name] || :twitter, consumer_key, consumer_secret, client_options, options, &block)
22
22
  end
23
23
 
@@ -0,0 +1,63 @@
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ # OAuth 2.0 based authentication with GitHub. In order to
7
+ # sign up for an application, you need to [register an application](http://github.com/account/applications/new)
8
+ # and provide the proper credentials to this middleware.
9
+ class Yammer < OmniAuth::Strategies::OAuth2
10
+ def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
11
+ client_options = {
12
+ :token_url => '/oauth2/access_token.json',
13
+ :authorize_url => '/dialog/oauth',
14
+ :site => 'https://www.yammer.com'
15
+ }
16
+ super(app, :yammer, client_id, client_secret, client_options, options, &block)
17
+ end
18
+
19
+ def auth_hash
20
+ OmniAuth::Utils.deep_merge(
21
+ super, {
22
+ 'uid' => user_hash['id'],
23
+ 'user_info' => user_info,
24
+ 'extra' => {
25
+ 'user_hash' => user_hash,
26
+ },
27
+ }
28
+ )
29
+ end
30
+
31
+ def user_info
32
+ user_hash = self.user_hash
33
+ {
34
+ 'nickname' => user_hash['name'],
35
+ 'name' => user_hash['full_name'],
36
+ 'location' => user_hash['location'],
37
+ 'image' => user_hash['mugshot_url'],
38
+ 'description' => user_hash['job_title'],
39
+ 'email' => user_hash['contact']['email_addresses'][0]['address'],
40
+ 'urls' => {
41
+ 'Yammer' => user_hash['web_url'],
42
+ },
43
+ }
44
+ end
45
+
46
+ def build_access_token
47
+ # Dance to get the real token out of the object returned by Yammer
48
+ verifier = request.params['code']
49
+ temp_access_token = client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(options))
50
+ token = eval(temp_access_token.token)['token']
51
+ @access_token = ::OAuth2::AccessToken.new(client, token, temp_access_token.params)
52
+ rescue ::OAuth2::Error => e
53
+ raise e.response.inspect
54
+ end
55
+
56
+ def user_hash
57
+ @user_hash ||= MultiJson.decode(@access_token.get('/api/v1/users/current.json').body)
58
+ end
59
+
60
+
61
+ end
62
+ end
63
+ end
@@ -10,7 +10,7 @@ module OmniAuth
10
10
  PATCH = 0
11
11
  end
12
12
  unless defined?(::OmniAuth::Version::PRE)
13
- PRE = "rc3"
13
+ PRE = nil
14
14
  end
15
15
  unless defined?(::OmniAuth::Version::STRING)
16
16
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
@@ -4,7 +4,7 @@ require File.expand_path('../lib/omniauth/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.add_dependency 'faraday', '~> 0.7.3'
6
6
  gem.add_dependency 'multi_json', '~> 1.0.0'
7
- gem.add_dependency 'multi_xml', '~> 0.3.0'
7
+ gem.add_dependency 'multi_xml', '~> 0.4.0'
8
8
  gem.add_dependency 'oa-core', OmniAuth::Version::STRING
9
9
  gem.add_dependency 'oauth', '~> 0.4.0'
10
10
  gem.add_dependency 'oauth2', '~> 0.5.0'
@@ -13,9 +13,9 @@ describe OmniAuth::Strategies::Twitter do
13
13
  }.to_app
14
14
  end
15
15
 
16
- it 'should use the authorize path by default' do
16
+ it 'should use the authenticate path by default' do
17
17
  s = strategy_class.new(app, 'abc', 'def')
18
- s.consumer.options[:authorize_path].should == '/oauth/authorize'
18
+ s.consumer.options[:authorize_path].should == '/oauth/authenticate'
19
19
  end
20
20
 
21
21
  it 'should set options[:authorize_params] to { :force_login => "true" } if :force_login is true' do
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Yammer do
4
- it_should_behave_like 'an oauth strategy'
4
+ it_should_behave_like 'an oauth2 strategy'
5
5
  end
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oa-oauth
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424035
5
- prerelease: 6
4
+ hash: 19
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
9
  - 0
10
- - rc
11
- - 3
12
- version: 0.3.0.rc3
10
+ version: 0.3.0
13
11
  platform: ruby
14
12
  authors:
15
13
  - Michael Bleigh
@@ -18,7 +16,8 @@ autorequire:
18
16
  bindir: bin
19
17
  cert_chain: []
20
18
 
21
- date: 2011-09-03 00:00:00 Z
19
+ date: 2011-09-22 00:00:00 -05:00
20
+ default_executable:
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
24
23
  name: faraday
@@ -60,12 +59,12 @@ dependencies:
60
59
  requirements:
61
60
  - - ~>
62
61
  - !ruby/object:Gem::Version
63
- hash: 19
62
+ hash: 15
64
63
  segments:
65
64
  - 0
66
- - 3
65
+ - 4
67
66
  - 0
68
- version: 0.3.0
67
+ version: 0.4.0
69
68
  type: :runtime
70
69
  version_requirements: *id003
71
70
  - !ruby/object:Gem::Dependency
@@ -76,14 +75,12 @@ dependencies:
76
75
  requirements:
77
76
  - - "="
78
77
  - !ruby/object:Gem::Version
79
- hash: 15424035
78
+ hash: 19
80
79
  segments:
81
80
  - 0
82
81
  - 3
83
82
  - 0
84
- - rc
85
- - 3
86
- version: 0.3.0.rc3
83
+ version: 0.3.0
87
84
  type: :runtime
88
85
  version_requirements: *id004
89
86
  - !ruby/object:Gem::Dependency
@@ -309,7 +306,6 @@ files:
309
306
  - lib/omniauth/strategies/oauth/type_pad.rb
310
307
  - lib/omniauth/strategies/oauth/vimeo.rb
311
308
  - lib/omniauth/strategies/oauth/yahoo.rb
312
- - lib/omniauth/strategies/oauth/yammer.rb
313
309
  - lib/omniauth/strategies/oauth/you_tube.rb
314
310
  - lib/omniauth/strategies/oauth2.rb
315
311
  - lib/omniauth/strategies/oauth2/angellist.rb
@@ -336,6 +332,7 @@ files:
336
332
  - lib/omniauth/strategies/oauth2/viadeo.rb
337
333
  - lib/omniauth/strategies/oauth2/vkontakte.rb
338
334
  - lib/omniauth/strategies/oauth2/we_pay.rb
335
+ - lib/omniauth/strategies/oauth2/yammer.rb
339
336
  - lib/omniauth/strategies/xauth.rb
340
337
  - lib/omniauth/strategies/xauth/instapaper.rb
341
338
  - lib/omniauth/version.rb
@@ -373,7 +370,6 @@ files:
373
370
  - spec/omniauth/strategies/oauth/type_pad_spec.rb
374
371
  - spec/omniauth/strategies/oauth/vimeo_spec.rb
375
372
  - spec/omniauth/strategies/oauth/yahoo_spec.rb
376
- - spec/omniauth/strategies/oauth/yammer_spec.rb
377
373
  - spec/omniauth/strategies/oauth/you_tube_spec.rb
378
374
  - spec/omniauth/strategies/oauth2/angellist_spec.rb
379
375
  - spec/omniauth/strategies/oauth2/bitly_spec.rb
@@ -397,8 +393,10 @@ files:
397
393
  - spec/omniauth/strategies/oauth2/viadeo_spec.rb
398
394
  - spec/omniauth/strategies/oauth2/vkontakte_spec.rb
399
395
  - spec/omniauth/strategies/oauth2/we_pay_spec.rb
396
+ - spec/omniauth/strategies/oauth2/yammer_spec.rb
400
397
  - spec/spec_helper.rb
401
398
  - spec/support/shared_examples.rb
399
+ has_rdoc: true
402
400
  homepage: http://github.com/intridea/omniauth
403
401
  licenses: []
404
402
 
@@ -419,18 +417,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
419
417
  required_rubygems_version: !ruby/object:Gem::Requirement
420
418
  none: false
421
419
  requirements:
422
- - - ">"
420
+ - - ">="
423
421
  - !ruby/object:Gem::Version
424
- hash: 25
422
+ hash: 23
425
423
  segments:
426
424
  - 1
427
425
  - 3
428
- - 1
429
- version: 1.3.1
426
+ - 6
427
+ version: 1.3.6
430
428
  requirements: []
431
429
 
432
430
  rubyforge_project:
433
- rubygems_version: 1.8.10
431
+ rubygems_version: 1.6.2
434
432
  signing_key:
435
433
  specification_version: 3
436
434
  summary: OAuth strategies for OmniAuth.
@@ -468,7 +466,6 @@ test_files:
468
466
  - spec/omniauth/strategies/oauth/type_pad_spec.rb
469
467
  - spec/omniauth/strategies/oauth/vimeo_spec.rb
470
468
  - spec/omniauth/strategies/oauth/yahoo_spec.rb
471
- - spec/omniauth/strategies/oauth/yammer_spec.rb
472
469
  - spec/omniauth/strategies/oauth/you_tube_spec.rb
473
470
  - spec/omniauth/strategies/oauth2/angellist_spec.rb
474
471
  - spec/omniauth/strategies/oauth2/bitly_spec.rb
@@ -492,5 +489,6 @@ test_files:
492
489
  - spec/omniauth/strategies/oauth2/viadeo_spec.rb
493
490
  - spec/omniauth/strategies/oauth2/vkontakte_spec.rb
494
491
  - spec/omniauth/strategies/oauth2/we_pay_spec.rb
492
+ - spec/omniauth/strategies/oauth2/yammer_spec.rb
495
493
  - spec/spec_helper.rb
496
494
  - spec/support/shared_examples.rb
@@ -1,48 +0,0 @@
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
- :access_token_path => '/oauth/access_token',
10
- :authorize_path => '/oauth/authorize',
11
- :request_token_path => '/oauth/request_token',
12
- :site => 'https://www.yammer.com',
13
- }
14
- super(app, :yammer, consumer_key, consumer_secret, client_options, options, &block)
15
- end
16
-
17
- def auth_hash
18
- OmniAuth::Utils.deep_merge(
19
- super, {
20
- 'uid' => user_hash['id'],
21
- 'user_info' => user_info,
22
- 'extra' => {
23
- 'user_hash' => user_hash,
24
- },
25
- }
26
- )
27
- end
28
-
29
- def user_info
30
- user_hash = self.user_hash
31
- {
32
- 'nickname' => user_hash['name'],
33
- 'name' => user_hash['full-name'],
34
- 'location' => user_hash['location'],
35
- 'image' => user_hash['mugshot-url'],
36
- 'description' => user_hash['job-title'],
37
- 'urls' => {
38
- 'Yammer' => user_hash['web-url'],
39
- },
40
- }
41
- end
42
-
43
- def user_hash
44
- @user_hash ||= MultiJson.decode(@access_token.get('/api/v1/users/current.json').body)
45
- end
46
- end
47
- end
48
- end