oauth2 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,5 +4,4 @@ rvm:
4
4
  - 1.9.3
5
5
  - jruby
6
6
  - rbx
7
- - rbx-2.0
8
7
  - ree
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/README.md CHANGED
@@ -1,18 +1,25 @@
1
- # OAuth2
2
- A Ruby wrapper for the OAuth 2.0 specification. This is a work in progress, being built first to solve the pragmatic process of connecting to existing OAuth 2.0 endpoints (a.k.a. Facebook) with the goal of building it up to meet the entire specification over time.
1
+ # OAuth2 [![Build Status](https://secure.travis-ci.org/intridea/oauth2.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/intridea/oauth2.png?travis)][gemnasium]
2
+ A Ruby wrapper for the OAuth 2.0 specification. This is a work in progress,
3
+ being built first to solve the pragmatic process of connecting to existing
4
+ OAuth 2.0 endpoints (a.k.a. Facebook) with the goal of building it up to meet
5
+ the entire specification over time.
3
6
 
4
- ## <a name="installation">Installation</a>
7
+ [travis]: http://travis-ci.org/intridea/oauth2
8
+ [gemnasium]: https://gemnasium.com/intridea/oauth2
9
+
10
+ ## <a name="installation"></a>Installation
5
11
  gem install oauth2
6
12
 
7
- ## <a name="ci">Continuous Integration</a>
8
- [![Build Status](https://secure.travis-ci.org/intridea/oauth2.png)](http://travis-ci.org/intridea/oauth2)
13
+ ## <a name="resources"></a>Resources
14
+ * [View Source on GitHub][code]
15
+ * [Report Issues on GitHub][issues]
16
+ * [Read More at the Wiki][wiki]
9
17
 
10
- ## <a name="resources">Resources</a>
11
- * View Source on GitHub (https://github.com/intridea/oauth2)
12
- * Report Issues on GitHub (https://github.com/intridea/oauth2/issues)
13
- * Read More at the Wiki (https://wiki.github.com/intridea/oauth2)
18
+ [code]: https://github.com/intridea/oauth2
19
+ [issues]: https://github.com/intridea/oauth2/issues
20
+ [wiki]: https://wiki.github.com/intridea/oauth2
14
21
 
15
- ## <a name="examples">Usage Examples</a>
22
+ ## <a name="examples"></a>Usage Examples
16
23
  require 'oauth2'
17
24
  client = OAuth2::Client.new('client_id', 'client_secret', :site => 'https://example.org')
18
25
 
@@ -24,50 +31,80 @@ A Ruby wrapper for the OAuth 2.0 specification. This is a work in progress, bein
24
31
  response.class.name
25
32
  # => OAuth2::Response
26
33
 
27
- ## <a name="response">OAuth2::Response</a>
28
- The AccessToken methods #get, #post, #put and #delete and the generic #request will return an instance of the #OAuth2::Response class.
29
- This instance contains a #parsed method that will parse the response body and return a Hash if the Content-Type is application/x-www-form-urlencoded or if the body is a JSON object. It will return an Array if the body is a JSON array. Otherwise, it will return the original body string.
30
-
31
- The original response body, headers, and status can be accessed via their respective methods.
32
-
33
- ## <a name="access_token">OAuth2::AccessToken</a>
34
- If you have an existing Access Token for a user, you can initialize an instance using various class methods including the standard new, from_hash (if you have a hash of the values), or from_kvform (if you have an application/x-www-form-urlencoded encoded string of the values).
35
-
36
- ## <a name="error">OAuth2::Error</a>
37
- On 400+ status code responses, an OAuth2::Error will be raised. If it is a standard OAuth2 error response, the body will be parsed and #code and #description will contain the values provided from the error and error_description parameters. The #response property of OAuth2::Error will always contain the OAuth2::Response instance.
38
-
39
- If you do not want an error to be raised, you may use :raise_errors => false option on initialization of the client. In this case the OAuth2::Response instance will be returned as usual and on 400+ status code responses, the Response instance will contain the OAuth2::Error instance.
40
-
41
- ## <a name="authorization_grants">Authorization Grants</a>
42
- Currently the Authorization Code and Resource Owner Password Credentials authentication grant types have helper strategy classes that simplify client use. They are available via the #auth_code and #password methods respectively.
43
-
44
- auth_url = client.auth_code.authorization_url(:redirect_uri => 'http://localhost:8080/oauth/callback')
34
+ ## <a name="response"></a>OAuth2::Response
35
+ The AccessToken methods #get, #post, #put and #delete and the generic #request
36
+ will return an instance of the #OAuth2::Response class.
37
+
38
+ This instance contains a #parsed method that will parse the response body and
39
+ return a Hash if the Content-Type is application/x-www-form-urlencoded or if
40
+ the body is a JSON object. It will return an Array if the body is a JSON
41
+ array. Otherwise, it will return the original body string.
42
+
43
+ The original response body, headers, and status can be accessed via their
44
+ respective methods.
45
+
46
+ ## <a name="access_token"></a>OAuth2::AccessToken
47
+ If you have an existing Access Token for a user, you can initialize an instance
48
+ using various class methods including the standard new, from_hash (if you have
49
+ a hash of the values), or from_kvform (if you have an
50
+ application/x-www-form-urlencoded encoded string of the values).
51
+
52
+ ## <a name="error"></a>OAuth2::Error
53
+ On 400+ status code responses, an OAuth2::Error will be raised. If it is a
54
+ standard OAuth2 error response, the body will be parsed and #code and
55
+ #description will contain the values provided from the error and
56
+ error_description parameters. The #response property of OAuth2::Error will
57
+ always contain the OAuth2::Response instance.
58
+
59
+ If you do not want an error to be raised, you may use :raise_errors => false
60
+ option on initialization of the client. In this case the OAuth2::Response
61
+ instance will be returned as usual and on 400+ status code responses, the
62
+ Response instance will contain the OAuth2::Error instance.
63
+
64
+ ## <a name="authorization_grants"></a>Authorization Grants
65
+ Currently the Authorization Code and Resource Owner Password Credentials
66
+ authentication grant types have helper strategy classes that simplify client
67
+ use. They are available via the #auth_code and #password methods respectively.
68
+
69
+ auth_url = client.auth_code.authorize_url(:redirect_uri => 'http://localhost:8080/oauth/callback')
45
70
  token = client.auth_code.get_token('code_value', :redirect_uri => 'http://localhost:8080/oauth/callback')
46
71
 
47
72
  token = client.password.get_token('username', 'password')
48
73
 
49
- You can always use the #request method on the OAuth2::Client instance to make requests for tokens for any Authentication grant type.
74
+ You can always use the #request method on the OAuth2::Client instance to make
75
+ requests for tokens for any Authentication grant type.
50
76
 
51
- ## <a name="pulls">Submitting a Pull Request</a>
77
+ ## <a name="pulls"></a>Submitting a Pull Request
52
78
  1. Fork the project.
53
79
  2. Create a topic branch.
54
80
  3. Implement your feature or bug fix.
55
81
  4. Add documentation for your feature or bug fix.
56
82
  5. Add specs for your feature or bug fix.
57
- 6. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 5.
83
+ 6. Run `bundle exec rake spec`. If your changes are not 100% covered, go back
84
+ to step 5.
58
85
  7. Commit and push your changes.
59
- 8. Submit a pull request. Please do not include changes to the [gemspec](https://github.com/intridea/oauth2/blob/master/oauth2.gemspec), [version](https://github.com/intridea/oauth2/blob/master/lib/oauth2/version.rb), or [changelog](https://github.com/intridea/oauth2/wiki/Changelg) . (If you want to create your own version for some reason, please do so in a separate commit.)
86
+ 8. Submit a pull request. Please do not include changes to the [gemspec][],
87
+ [version][], or [changelog][]. (If you want to create your own version for
88
+ some reason, please do so in a separate commit.)
60
89
 
61
- ## <a name="rubies">Supported Rubies</a>
62
- This library aims to support and is [tested
63
- against](http://travis-ci.org/intridea/oauth2) the following Ruby
90
+ [gemspec]: https://github.com/intridea/oauth2/blob/master/oauth2.gemspec
91
+ [version]: https://github.com/intridea/oauth2/blob/master/lib/oauth2/version.rb
92
+ [changelog]: https://github.com/intridea/oauth2/wiki/Changelog
93
+
94
+ ## <a name="versions"></a>Supported Ruby Versions
95
+ This library aims to support and is [tested against][travis] the following Ruby
64
96
  implementations:
65
97
 
66
98
  * Ruby 1.8.7
67
99
  * Ruby 1.9.2
68
- * [JRuby](http://www.jruby.org/)
69
- * [Rubinius](http://rubini.us/)
70
- * [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com/)
100
+ * Ruby 1.9.3
101
+ * [JRuby][]
102
+ * [Rubinius][]
103
+ * [Ruby Enterprise Edition][ree]
104
+
105
+ [jruby]: http://www.jruby.org/
106
+ [rubinius]: http://rubini.us/
107
+ [ree]: http://www.rubyenterpriseedition.com/
71
108
 
72
109
  If something doesn't work on one of these interpreters, it should be considered
73
110
  a bug.
@@ -83,6 +120,7 @@ implementation, you will be personally responsible for providing patches in a
83
120
  timely fashion. If critical issues for a particular implementation exist at the
84
121
  time of a major release, support for that Ruby version may be dropped.
85
122
 
86
- ## <a name="copyright">Copyright</a>
123
+ ## <a name="copyright"></a>Copyright
87
124
  Copyright (c) 2011 Intridea, Inc. and Michael Bleigh.
88
- See [LICENSE](https://github.com/intridea/oauth2/blob/master/LICENSE.md) for details.
125
+ See [LICENSE][] for details.
126
+ [license]: https://github.com/intridea/oauth2/blob/master/LICENSE.md
@@ -118,7 +118,7 @@ module OAuth2
118
118
  # @param [Hash] access token options, to pass to the AccessToken object
119
119
  # @return [AccessToken] the initalized AccessToken
120
120
  def get_token(params, access_token_opts={})
121
- opts = {:raise_errors => true, :parse => params.delete(:parse)}
121
+ opts = {:raise_errors => options[:raise_errors], :parse => params.delete(:parse)}
122
122
  if options[:token_method] == :post
123
123
  opts[:body] = params
124
124
  opts[:headers] = {'Content-Type' => 'application/x-www-form-urlencoded'}
@@ -126,7 +126,7 @@ module OAuth2
126
126
  opts[:params] = params
127
127
  end
128
128
  response = request(options[:token_method], token_url, opts)
129
- raise Error.new(response) unless response.parsed.is_a?(Hash) && response.parsed['access_token']
129
+ raise Error.new(response) if options[:raise_errors] && !(response.parsed.is_a?(Hash) && response.parsed['access_token'])
130
130
  AccessToken.from_hash(self, response.parsed.merge(access_token_opts))
131
131
  end
132
132
 
@@ -1,3 +1,3 @@
1
1
  module OAuth2
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -2,14 +2,14 @@
2
2
  require File.expand_path('../lib/oauth2/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.add_dependency 'faraday', '~> 0.7.4'
6
- gem.add_dependency 'multi_json', '~> 1.0.3'
7
- gem.add_development_dependency 'multi_xml', '~> 0.4'
8
- gem.add_development_dependency 'rake', '~> 0.9'
9
- gem.add_development_dependency 'rdoc', '~> 3.9'
10
- gem.add_development_dependency 'rspec', '~> 2.6'
11
- gem.add_development_dependency 'simplecov', '~> 0.4'
12
- gem.add_development_dependency 'yard', '~> 0.7'
5
+ gem.add_dependency 'faraday', '~> 0.7'
6
+ gem.add_dependency 'multi_json', '~> 1.0'
7
+ gem.add_development_dependency 'multi_xml'
8
+ gem.add_development_dependency 'rake'
9
+ gem.add_development_dependency 'rdoc'
10
+ gem.add_development_dependency 'rspec'
11
+ gem.add_development_dependency 'simplecov'
12
+ gem.add_development_dependency 'yard'
13
13
  gem.authors = ["Michael Bleigh", "Erik Michaels-Ober"]
14
14
  gem.description = %q{A Ruby wrapper for the OAuth 2.0 protocol built with a similar style to the original OAuth gem.}
15
15
  gem.email = ['michael@intridea.com', 'sferik@gmail.com']
@@ -1,5 +1,3 @@
1
- $:.unshift File.expand_path('..', __FILE__)
2
- $:.unshift File.expand_path('../../lib', __FILE__)
3
1
  require 'simplecov'
4
2
  SimpleCov.start
5
3
  require 'oauth2'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,96 +10,96 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-26 00:00:00.000000000Z
13
+ date: 2012-01-04 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
17
- requirement: &70341369880920 !ruby/object:Gem::Requirement
17
+ requirement: &70259907739420 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 0.7.4
22
+ version: '0.7'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70341369880920
25
+ version_requirements: *70259907739420
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: multi_json
28
- requirement: &70341369879920 !ruby/object:Gem::Requirement
28
+ requirement: &70259907738920 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.3
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70341369879920
36
+ version_requirements: *70259907738920
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: multi_xml
39
- requirement: &70341369879020 !ruby/object:Gem::Requirement
39
+ requirement: &70259907738540 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
- - - ~>
42
+ - - ! '>='
43
43
  - !ruby/object:Gem::Version
44
- version: '0.4'
44
+ version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70341369879020
47
+ version_requirements: *70259907738540
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rake
50
- requirement: &70341369878180 !ruby/object:Gem::Requirement
50
+ requirement: &70259907738080 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
- - - ~>
53
+ - - ! '>='
54
54
  - !ruby/object:Gem::Version
55
- version: '0.9'
55
+ version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70341369878180
58
+ version_requirements: *70259907738080
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rdoc
61
- requirement: &70341369877680 !ruby/object:Gem::Requirement
61
+ requirement: &70259907737660 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
- - - ~>
64
+ - - ! '>='
65
65
  - !ruby/object:Gem::Version
66
- version: '3.9'
66
+ version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70341369877680
69
+ version_requirements: *70259907737660
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec
72
- requirement: &70341369876980 !ruby/object:Gem::Requirement
72
+ requirement: &70259907737240 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ~>
75
+ - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
- version: '2.6'
77
+ version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70341369876980
80
+ version_requirements: *70259907737240
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: simplecov
83
- requirement: &70341369860040 !ruby/object:Gem::Requirement
83
+ requirement: &70259907767020 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
- - - ~>
86
+ - - ! '>='
87
87
  - !ruby/object:Gem::Version
88
- version: '0.4'
88
+ version: '0'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *70341369860040
91
+ version_requirements: *70259907767020
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: yard
94
- requirement: &70341369858660 !ruby/object:Gem::Requirement
94
+ requirement: &70259907766600 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
- - - ~>
97
+ - - ! '>='
98
98
  - !ruby/object:Gem::Version
99
- version: '0.7'
99
+ version: '0'
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *70341369858660
102
+ version_requirements: *70259907766600
103
103
  description: A Ruby wrapper for the OAuth 2.0 protocol built with a similar style
104
104
  to the original OAuth gem.
105
105
  email:
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: 1.3.6
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 1.8.10
158
+ rubygems_version: 1.8.13
159
159
  signing_key:
160
160
  specification_version: 3
161
161
  summary: A Ruby wrapper for the OAuth 2.0 protocol.
@@ -167,3 +167,4 @@ test_files:
167
167
  - spec/oauth2/strategy/auth_code_spec.rb
168
168
  - spec/oauth2/strategy/base_spec.rb
169
169
  - spec/oauth2/strategy/password_spec.rb
170
+ has_rdoc: