omniauth-oauth2 1.0.0.pr2 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of omniauth-oauth2 might be problematic. Click here for more details.

data/Gemfile CHANGED
@@ -1,6 +1,5 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'omniauth', '1.0.0.alpha', :git => 'git://github.com/intridea/omniauth.git'
4
3
  # Specify your gem's dependencies in omniauth-oauth2.gemspec
5
4
  gemspec
6
5
 
data/README.md CHANGED
@@ -18,7 +18,7 @@ subclass it and add a few extra methods like so:
18
18
 
19
19
  module OmniAuth
20
20
  module Strategies
21
- class SomeSite
21
+ class SomeSite < OmniAuth::Strategies::OAuth2
22
22
  # Give your strategy a name.
23
23
  option :name, "some_site"
24
24
 
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module OAuth2
3
- VERSION = "1.0.0.pr2"
3
+ VERSION = "1.0.0.rc1"
4
4
  end
5
5
  end
@@ -19,7 +19,9 @@ module OmniAuth
19
19
  option :client_secret, nil
20
20
  option :client_options, {}
21
21
  option :authorize_params, {}
22
+ option :authorize_options, [:scope]
22
23
  option :token_params, {}
24
+ option :token_options, []
23
25
 
24
26
  attr_accessor :access_token
25
27
 
@@ -33,12 +35,22 @@ module OmniAuth
33
35
 
34
36
  credentials do
35
37
  hash = {'token' => access_token.token}
36
- hash.merge!('refresh_token' => access_token.refresh_token) if access_token.expires?
38
+ hash.merge!('refresh_token' => access_token.refresh_token) if access_token.expires? && access_token.refresh_token
39
+ hash.merge!('expires_at' => access_token.expires_at) if access_token.expires?
40
+ hash.merge!('expires' => access_token.expires?)
37
41
  hash
38
42
  end
39
43
 
40
44
  def request_phase
41
- redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(options.authorize_params))
45
+ redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(authorize_params))
46
+ end
47
+
48
+ def authorize_params
49
+ options.authorize_params.merge(options.authorize_options.inject({}){|h,k| h[k.to_sym] = options[k] if options[k]; h})
50
+ end
51
+
52
+ def token_params
53
+ options.token_params.merge(options.token_options.inject({}){|h,k| h[k.to_sym] = options[k] if options[k]; h})
42
54
  end
43
55
 
44
56
  def callback_phase
@@ -62,9 +74,7 @@ module OmniAuth
62
74
 
63
75
  def build_access_token
64
76
  verifier = request.params['code']
65
- client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(options.token_params.to_hash.inject({}){|h,(k,v)| h[k.to_sym] = v; h}))
66
- rescue ::OAuth2::Error => e
67
- raise e.response.inspect
77
+ client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(options.token_params.to_hash(:symbolize_keys => true)))
68
78
  end
69
79
 
70
80
  # An error that is indicated in the OAuth 2.0 callback.
@@ -2,7 +2,8 @@
2
2
  require File.expand_path('../lib/omniauth-oauth2/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.add_dependency 'omniauth', '~> 1.0.0.pr2'
5
+ gem.add_dependency 'hashie', '~> 1.2'
6
+ gem.add_dependency 'omniauth', '1.0.0.beta1'
6
7
  gem.add_dependency 'oauth2', '~> 0.5.0'
7
8
 
8
9
  gem.add_development_dependency 'rspec', '~> 2.6'
@@ -12,4 +12,32 @@ describe OmniAuth::Strategies::OAuth2 do
12
12
  instance.client.options[:authorize_url].should == 'https://example.com'
13
13
  end
14
14
  end
15
+
16
+ describe '#authorize_params' do
17
+ subject { fresh_strategy }
18
+
19
+ it 'should include any authorize params passed in the :authorize_params option' do
20
+ instance = subject.new('abc', 'def', :authorize_params => {:foo => 'bar', :baz => 'zip'})
21
+ instance.authorize_params.should == {'foo' => 'bar', 'baz' => 'zip'}
22
+ end
23
+
24
+ it 'should include top-level options that are marked as :authorize_options' do
25
+ instance = subject.new('abc', 'def', :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz')
26
+ instance.authorize_params.should == {'scope' => 'bar', 'foo' => 'baz'}
27
+ end
28
+ end
29
+
30
+ describe '#token_params' do
31
+ subject { fresh_strategy }
32
+
33
+ it 'should include any authorize params passed in the :authorize_params option' do
34
+ instance = subject.new('abc', 'def', :token_params => {:foo => 'bar', :baz => 'zip'})
35
+ instance.token_params.should == {'foo' => 'bar', 'baz' => 'zip'}
36
+ end
37
+
38
+ it 'should include top-level options that are marked as :authorize_options' do
39
+ instance = subject.new('abc', 'def', :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz')
40
+ instance.token_params.should == {'scope' => 'bar', 'foo' => 'baz'}
41
+ end
42
+ end
15
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pr2
4
+ version: 1.0.0.rc1
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-13 00:00:00.000000000Z
12
+ date: 2011-10-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: omniauth
16
- requirement: &70247627053560 !ruby/object:Gem::Requirement
15
+ name: hashie
16
+ requirement: &70331647759620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.0.pr2
21
+ version: '1.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70331647759620
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth
27
+ requirement: &70331647759120 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - =
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0.beta1
22
33
  type: :runtime
23
34
  prerelease: false
24
- version_requirements: *70247627053560
35
+ version_requirements: *70331647759120
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: oauth2
27
- requirement: &70247627053060 !ruby/object:Gem::Requirement
38
+ requirement: &70331647758620 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ~>
@@ -32,10 +43,10 @@ dependencies:
32
43
  version: 0.5.0
33
44
  type: :runtime
34
45
  prerelease: false
35
- version_requirements: *70247627053060
46
+ version_requirements: *70331647758620
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: rspec
38
- requirement: &70247627052600 !ruby/object:Gem::Requirement
49
+ requirement: &70331647758140 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ~>
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '2.6'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *70247627052600
57
+ version_requirements: *70331647758140
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: rack-test
49
- requirement: &70247627052220 !ruby/object:Gem::Requirement
60
+ requirement: &70331647757580 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *70247627052220
68
+ version_requirements: *70331647757580
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: webmock
60
- requirement: &70247627082720 !ruby/object:Gem::Requirement
71
+ requirement: &70331647757000 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ! '>='
@@ -65,10 +76,10 @@ dependencies:
65
76
  version: '0'
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *70247627082720
79
+ version_requirements: *70331647757000
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: simplecov
71
- requirement: &70247627082300 !ruby/object:Gem::Requirement
82
+ requirement: &70331647756420 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ! '>='
@@ -76,7 +87,7 @@ dependencies:
76
87
  version: '0'
77
88
  type: :development
78
89
  prerelease: false
79
- version_requirements: *70247627082300
90
+ version_requirements: *70331647756420
80
91
  description: An abstract OAuth2 strategy for OmniAuth.
81
92
  email:
82
93
  - michael@intridea.com