oauth2 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  rvm:
2
2
  - 1.8.7
3
3
  - 1.9.2
4
+ - 1.9.3
5
+ - jruby
6
+ - rbx
7
+ - rbx-2.0
4
8
  - ree
5
- - ruby-head
data/README.md CHANGED
@@ -1,24 +1,18 @@
1
- OAuth2
2
- ======
1
+ # OAuth2
3
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.
4
3
 
5
- Installation
6
- ------------
4
+ ## <a name="installation">Installation</a>
7
5
  gem install oauth2
8
6
 
9
- Continuous Integration
10
- ----------------------
7
+ ## <a name="ci">Continuous Integration</a>
11
8
  [![Build Status](https://secure.travis-ci.org/intridea/oauth2.png)](http://travis-ci.org/intridea/oauth2)
12
9
 
13
- Resources
14
- ---------
10
+ ## <a name="resources">Resources</a>
15
11
  * View Source on GitHub (https://github.com/intridea/oauth2)
16
12
  * Report Issues on GitHub (https://github.com/intridea/oauth2/issues)
17
13
  * Read More at the Wiki (https://wiki.github.com/intridea/oauth2)
18
14
 
19
- Generic Client Example
20
- ----------------------
21
-
15
+ ## <a name="examples">Usage Examples</a>
22
16
  require 'oauth2'
23
17
  client = OAuth2::Client.new('client_id', 'client_secret', :site => 'https://example.org')
24
18
 
@@ -30,25 +24,21 @@ Generic Client Example
30
24
  response.class.name
31
25
  # => OAuth2::Response
32
26
 
33
- OAuth2::Response
34
- ----------------
27
+ ## <a name="response">OAuth2::Response</a>
35
28
  The AccessToken methods #get, #post, #put and #delete and the generic #request will return an instance of the #OAuth2::Response class.
36
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.
37
30
 
38
31
  The original response body, headers, and status can be accessed via their respective methods.
39
32
 
40
- OAuth2::AccessToken
41
- -------------------
33
+ ## <a name="access_token">OAuth2::AccessToken</a>
42
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).
43
35
 
44
- OAuth2::Error
45
- -------------
36
+ ## <a name="error">OAuth2::Error</a>
46
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.
47
38
 
48
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.
49
40
 
50
- Authorization Grants
51
- --------------------
41
+ ## <a name="authorization_grants">Authorization Grants</a>
52
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.
53
43
 
54
44
  auth_url = client.auth_code.authorization_url(:redirect_uri => 'http://localhost:8080/oauth/callback')
@@ -58,9 +48,7 @@ Currently the Authorization Code and Resource Owner Password Credentials authent
58
48
 
59
49
  You can always use the #request method on the OAuth2::Client instance to make requests for tokens for any Authentication grant type.
60
50
 
61
-
62
- Note on Patches/Pull Requests
63
- -----------------------------
51
+ ## <a name="pulls">Submitting a Pull Request</a>
64
52
  1. Fork the project.
65
53
  2. Create a topic branch.
66
54
  3. Implement your feature or bug fix.
@@ -70,15 +58,16 @@ Note on Patches/Pull Requests
70
58
  7. Commit and push your changes.
71
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.)
72
60
 
73
- Supported Rubies
74
- ----------------
61
+ ## <a name="rubies">Supported Rubies</a>
75
62
  This library aims to support and is [tested
76
63
  against](http://travis-ci.org/intridea/oauth2) the following Ruby
77
64
  implementations:
78
65
 
79
66
  * Ruby 1.8.7
80
67
  * Ruby 1.9.2
81
- * Ruby Enterprise Edition 1.8.7
68
+ * [JRuby](http://www.jruby.org/)
69
+ * [Rubinius](http://rubini.us/)
70
+ * [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com/)
82
71
 
83
72
  If something doesn't work on one of these interpreters, it should be considered
84
73
  a bug.
@@ -94,7 +83,6 @@ implementation, you will be personally responsible for providing patches in a
94
83
  timely fashion. If critical issues for a particular implementation exist at the
95
84
  time of a major release, support for that Ruby version may be dropped.
96
85
 
97
- Copyright
98
- ---------
86
+ ## <a name="copyright">Copyright</a>
99
87
  Copyright (c) 2011 Intridea, Inc. and Michael Bleigh.
100
88
  See [LICENSE](https://github.com/intridea/oauth2/blob/master/LICENSE.md) for details.
data/Rakefile CHANGED
@@ -9,10 +9,13 @@ RSpec::Core::RakeTask.new(:spec)
9
9
  task :default => :spec
10
10
  task :test => :spec
11
11
 
12
- require 'rdoc/task'
13
- Rake::RDocTask.new do |rdoc|
14
- rdoc.rdoc_dir = 'rdoc'
15
- rdoc.title = "oauth2 #{OAuth2::VERSION}"
16
- rdoc.rdoc_files.include('README*')
17
- rdoc.rdoc_files.include('lib/**/*.rb')
12
+ namespace :doc do
13
+ require 'rdoc/task'
14
+ require File.expand_path('../lib/oauth2/version', __FILE__)
15
+ RDoc::Task.new do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = "oauth2 #{OAuth2::VERSION}"
18
+ rdoc.main = 'README.md'
19
+ rdoc.rdoc_files.include('README.md', 'LICENSE.md', 'lib/**/*.rb')
20
+ end
18
21
  end
data/lib/oauth2/client.rb CHANGED
@@ -115,8 +115,9 @@ module OAuth2
115
115
  # Initializes an AccessToken by making a request to the token endpoint
116
116
  #
117
117
  # @param [Hash] params a Hash of params for the token endpoint
118
+ # @param [Hash] access token options, to pass to the AccessToken object
118
119
  # @return [AccessToken] the initalized AccessToken
119
- def get_token(params)
120
+ def get_token(params, access_token_opts={})
120
121
  opts = {:raise_errors => true, :parse => params.delete(:parse)}
121
122
  if options[:token_method] == :post
122
123
  opts[:body] = params
@@ -126,7 +127,7 @@ module OAuth2
126
127
  end
127
128
  response = request(options[:token_method], token_url, opts)
128
129
  raise Error.new(response) unless response.parsed.is_a?(Hash) && response.parsed['access_token']
129
- AccessToken.from_hash(self, response.parsed)
130
+ AccessToken.from_hash(self, response.parsed.merge(access_token_opts))
130
131
  end
131
132
 
132
133
  # The Authorization Code strategy
@@ -23,7 +23,7 @@ module OAuth2
23
23
  #
24
24
  # @param [Faraday::Response] response The Faraday response instance
25
25
  # @param [Hash] opts options in which to initialize the instance
26
- # @option opts [Symbol] :parse (:automatic) how to parse the response body. one of :url (for x-www-form-urlencoded),
26
+ # @option opts [Symbol] :parse (:automatic) how to parse the response body. one of :query (for x-www-form-urlencoded),
27
27
  # :json, or :automatic (determined by Content-Type response header)
28
28
  def initialize(response, opts={})
29
29
  @response = response
@@ -22,10 +22,11 @@ module OAuth2
22
22
  #
23
23
  # @param [String] code The Authorization Code value
24
24
  # @param [Hash] params additional params
25
+ # @param [Hash] opts options
25
26
  # @note that you must also provide a :redirect_uri with most OAuth 2.0 providers
26
- def get_token(code, params={})
27
+ def get_token(code, params={}, opts={})
27
28
  params = {'grant_type' => 'authorization_code', 'code' => code}.merge(client_params).merge(params)
28
- @client.get_token(params)
29
+ @client.get_token(params, opts)
29
30
  end
30
31
  end
31
32
  end
@@ -16,11 +16,11 @@ module OAuth2
16
16
  # @param [String] username the End User username
17
17
  # @param [String] password the End User password
18
18
  # @param [Hash] params additional params
19
- def get_token(username, password, params={})
19
+ def get_token(username, password, params={}, opts={})
20
20
  params = {'grant_type' => 'password',
21
21
  'username' => username,
22
22
  'password' => password}.merge(client_params).merge(params)
23
- @client.get_token(params)
23
+ @client.get_token(params, opts)
24
24
  end
25
25
  end
26
26
  end
@@ -1,3 +1,3 @@
1
1
  module OAuth2
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
data/oauth2.gemspec CHANGED
@@ -1,20 +1,18 @@
1
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
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'
5
8
  gem.add_development_dependency 'rake', '~> 0.9'
6
- gem.add_development_dependency 'rdoc', '~> 3.6'
9
+ gem.add_development_dependency 'rdoc', '~> 3.9'
7
10
  gem.add_development_dependency 'rspec', '~> 2.6'
8
11
  gem.add_development_dependency 'simplecov', '~> 0.4'
9
12
  gem.add_development_dependency 'yard', '~> 0.7'
10
- gem.add_development_dependency 'ZenTest', '~> 4.5'
11
- gem.add_development_dependency 'multi_xml'
12
- gem.add_runtime_dependency 'faraday', ['>= 0.6.1', '< 0.8']
13
- gem.add_runtime_dependency 'multi_json', '~> 1.0.0'
14
13
  gem.authors = ["Michael Bleigh", "Erik Michaels-Ober"]
15
14
  gem.description = %q{A Ruby wrapper for the OAuth 2.0 protocol built with a similar style to the original OAuth gem.}
16
15
  gem.email = ['michael@intridea.com', 'sferik@gmail.com']
17
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
16
  gem.files = `git ls-files`.split("\n")
19
17
  gem.homepage = 'http://github.com/intridea/oauth2'
20
18
  gem.name = '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.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,110 +10,96 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-07-29 00:00:00.000000000 Z
13
+ date: 2011-09-26 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: rake
17
- requirement: &70092424464720 !ruby/object:Gem::Requirement
16
+ name: faraday
17
+ requirement: &70341369880920 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: '0.9'
23
- type: :development
22
+ version: 0.7.4
23
+ type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70092424464720
25
+ version_requirements: *70341369880920
26
26
  - !ruby/object:Gem::Dependency
27
- name: rdoc
28
- requirement: &70092424463940 !ruby/object:Gem::Requirement
27
+ name: multi_json
28
+ requirement: &70341369879920 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '3.6'
34
- type: :development
33
+ version: 1.0.3
34
+ type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70092424463940
36
+ version_requirements: *70341369879920
37
37
  - !ruby/object:Gem::Dependency
38
- name: rspec
39
- requirement: &70092424463400 !ruby/object:Gem::Requirement
38
+ name: multi_xml
39
+ requirement: &70341369879020 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
- version: '2.6'
44
+ version: '0.4'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70092424463400
47
+ version_requirements: *70341369879020
48
48
  - !ruby/object:Gem::Dependency
49
- name: simplecov
50
- requirement: &70092424462900 !ruby/object:Gem::Requirement
49
+ name: rake
50
+ requirement: &70341369878180 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
54
54
  - !ruby/object:Gem::Version
55
- version: '0.4'
55
+ version: '0.9'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70092424462900
58
+ version_requirements: *70341369878180
59
59
  - !ruby/object:Gem::Dependency
60
- name: yard
61
- requirement: &70092424462440 !ruby/object:Gem::Requirement
60
+ name: rdoc
61
+ requirement: &70341369877680 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
65
65
  - !ruby/object:Gem::Version
66
- version: '0.7'
66
+ version: '3.9'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70092424462440
69
+ version_requirements: *70341369877680
70
70
  - !ruby/object:Gem::Dependency
71
- name: ZenTest
72
- requirement: &70092424461860 !ruby/object:Gem::Requirement
71
+ name: rspec
72
+ requirement: &70341369876980 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: '4.5'
77
+ version: '2.6'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70092424461860
80
+ version_requirements: *70341369876980
81
81
  - !ruby/object:Gem::Dependency
82
- name: multi_xml
83
- requirement: &70092424461480 !ruby/object:Gem::Requirement
82
+ name: simplecov
83
+ requirement: &70341369860040 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
- - - ! '>='
86
+ - - ~>
87
87
  - !ruby/object:Gem::Version
88
- version: '0'
88
+ version: '0.4'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *70092424461480
91
+ version_requirements: *70341369860040
92
92
  - !ruby/object:Gem::Dependency
93
- name: faraday
94
- requirement: &70092424460880 !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ! '>='
98
- - !ruby/object:Gem::Version
99
- version: 0.6.1
100
- - - <
101
- - !ruby/object:Gem::Version
102
- version: '0.8'
103
- type: :runtime
104
- prerelease: false
105
- version_requirements: *70092424460880
106
- - !ruby/object:Gem::Dependency
107
- name: multi_json
108
- requirement: &70092424460060 !ruby/object:Gem::Requirement
93
+ name: yard
94
+ requirement: &70341369858660 !ruby/object:Gem::Requirement
109
95
  none: false
110
96
  requirements:
111
97
  - - ~>
112
98
  - !ruby/object:Gem::Version
113
- version: 1.0.0
114
- type: :runtime
99
+ version: '0.7'
100
+ type: :development
115
101
  prerelease: false
116
- version_requirements: *70092424460060
102
+ version_requirements: *70341369858660
117
103
  description: A Ruby wrapper for the OAuth 2.0 protocol built with a similar style
118
104
  to the original OAuth gem.
119
105
  email:
@@ -123,7 +109,6 @@ executables: []
123
109
  extensions: []
124
110
  extra_rdoc_files: []
125
111
  files:
126
- - .autotest
127
112
  - .document
128
113
  - .gemtest
129
114
  - .gitignore
@@ -170,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
155
  version: 1.3.6
171
156
  requirements: []
172
157
  rubyforge_project:
173
- rubygems_version: 1.8.5.1
158
+ rubygems_version: 1.8.10
174
159
  signing_key:
175
160
  specification_version: 3
176
161
  summary: A Ruby wrapper for the OAuth 2.0 protocol.
data/.autotest DELETED
@@ -1 +0,0 @@
1
- require 'autotest/bundler'