oauth2 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +10 -12
- data/Rakefile +1 -1
- data/lib/oauth2/access_token.rb +13 -4
- data/lib/oauth2/client.rb +1 -1
- data/lib/oauth2/strategy/web_server.rb +1 -1
- data/lib/oauth2/version.rb +2 -2
- data/oauth2.gemspec +3 -2
- data/spec/oauth2/strategy/web_server_spec.rb +6 -2
- metadata +6 -14
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
oauth2 (0.
|
4
|
+
oauth2 (0.1.1)
|
5
5
|
faraday (~> 0.5.0)
|
6
6
|
multi_json (~> 0.0.4)
|
7
7
|
|
@@ -20,16 +20,14 @@ GEM
|
|
20
20
|
rack (1.2.1)
|
21
21
|
rake (0.8.7)
|
22
22
|
rcov (0.9.9)
|
23
|
-
rspec (2.
|
24
|
-
rspec-core (
|
25
|
-
rspec-expectations (
|
26
|
-
rspec-mocks (
|
27
|
-
rspec-core (2.
|
28
|
-
rspec-expectations (2.
|
29
|
-
diff-lcs (
|
30
|
-
rspec-mocks (2.
|
31
|
-
rspec-core (= 2.0.0)
|
32
|
-
rspec-expectations (= 2.0.0)
|
23
|
+
rspec (2.4.0)
|
24
|
+
rspec-core (~> 2.4.0)
|
25
|
+
rspec-expectations (~> 2.4.0)
|
26
|
+
rspec-mocks (~> 2.4.0)
|
27
|
+
rspec-core (2.4.0)
|
28
|
+
rspec-expectations (2.4.0)
|
29
|
+
diff-lcs (~> 1.1.2)
|
30
|
+
rspec-mocks (2.4.0)
|
33
31
|
|
34
32
|
PLATFORMS
|
35
33
|
ruby
|
@@ -41,4 +39,4 @@ DEPENDENCIES
|
|
41
39
|
oauth2!
|
42
40
|
rake (~> 0.8)
|
43
41
|
rcov (~> 0.9)
|
44
|
-
rspec (~> 2.0)
|
42
|
+
rspec (~> 2.4.0)
|
data/Rakefile
CHANGED
@@ -25,7 +25,7 @@ task :default => :spec
|
|
25
25
|
require 'rake/rdoctask'
|
26
26
|
Rake::RDocTask.new do |rdoc|
|
27
27
|
rdoc.rdoc_dir = 'rdoc'
|
28
|
-
rdoc.title = "oauth2 #{
|
28
|
+
rdoc.title = "oauth2 #{OAuth2::VERSION}"
|
29
29
|
rdoc.rdoc_files.include('README*')
|
30
30
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
31
31
|
end
|
data/lib/oauth2/access_token.rb
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
module OAuth2
|
2
2
|
class AccessToken
|
3
3
|
attr_reader :client, :token, :refresh_token, :expires_in, :expires_at
|
4
|
+
attr_accessor :token_param
|
4
5
|
|
5
|
-
def initialize(client, token, refresh_token = nil, expires_in = nil)
|
6
|
+
def initialize(client, token, refresh_token = nil, expires_in = nil, params = {})
|
6
7
|
@client = client
|
7
|
-
@token = token
|
8
|
-
@refresh_token = refresh_token
|
8
|
+
@token = token.to_s
|
9
|
+
@refresh_token = refresh_token.to_s
|
9
10
|
@expires_in = (expires_in.nil? || expires_in == '') ? nil : expires_in.to_i
|
10
11
|
@expires_at = Time.now + @expires_in if @expires_in
|
12
|
+
@params = params
|
13
|
+
@token_param = 'access_token'
|
14
|
+
end
|
15
|
+
|
16
|
+
def [](key)
|
17
|
+
@params[key]
|
11
18
|
end
|
12
19
|
|
13
20
|
# True if the token in question has an expiration time.
|
@@ -16,7 +23,9 @@ module OAuth2
|
|
16
23
|
end
|
17
24
|
|
18
25
|
def request(verb, path, params = {}, headers = {})
|
19
|
-
|
26
|
+
params = params.merge token_param => @token
|
27
|
+
headers = headers.merge 'Authorization' => "OAuth #{@token}"
|
28
|
+
@client.request(verb, path, params, headers)
|
20
29
|
end
|
21
30
|
|
22
31
|
def get(path, params = {}, headers = {})
|
data/lib/oauth2/client.rb
CHANGED
@@ -24,7 +24,7 @@ module OAuth2
|
|
24
24
|
access = params['access_token']
|
25
25
|
refresh = params['refresh_token']
|
26
26
|
expires_in = params['expires_in']
|
27
|
-
OAuth2::AccessToken.new(@client, access, refresh, expires_in)
|
27
|
+
OAuth2::AccessToken.new(@client, access, refresh, expires_in, params)
|
28
28
|
end
|
29
29
|
|
30
30
|
# <b>DEPRECATED:</b> Use #get_access_token instead.
|
data/lib/oauth2/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = "0.1.
|
1
|
+
module OAuth2
|
2
|
+
VERSION = "0.1.1"
|
3
3
|
end
|
data/oauth2.gemspec
CHANGED
@@ -3,7 +3,8 @@ require File.expand_path("../lib/oauth2/version", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "oauth2"
|
6
|
-
s.version =
|
6
|
+
s.version = OAuth2::VERSION
|
7
|
+
s.rubyforge_project = 'oauth2'
|
7
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6") if s.respond_to? :required_rubygems_version=
|
8
9
|
s.authors = ["Michael Bleigh"]
|
9
10
|
s.description = %q{A Ruby wrapper for the OAuth 2.0 protocol built with a similar style to the original OAuth gem.}
|
@@ -21,5 +22,5 @@ Gem::Specification.new do |s|
|
|
21
22
|
s.add_development_dependency("json_pure", "~> 1.4.6")
|
22
23
|
s.add_development_dependency("rake", "~> 0.8")
|
23
24
|
s.add_development_dependency("rcov", "~> 0.9")
|
24
|
-
s.add_development_dependency("rspec", "~> 2.0")
|
25
|
+
s.add_development_dependency("rspec", "~> 2.4.0")
|
25
26
|
end
|
@@ -8,9 +8,9 @@ describe OAuth2::Strategy::WebServer do
|
|
8
8
|
stub.post('/oauth/access_token') do |env|
|
9
9
|
case @mode
|
10
10
|
when "formencoded"
|
11
|
-
[200, {}, 'expires_in=600&access_token=salmon&refresh_token=trout']
|
11
|
+
[200, {}, 'expires_in=600&access_token=salmon&refresh_token=trout&extra_param=steve']
|
12
12
|
when "json"
|
13
|
-
[200, {}, '{"expires_in":600,"access_token":"salmon","refresh_token":"trout"}']
|
13
|
+
[200, {}, '{"expires_in":600,"access_token":"salmon","refresh_token":"trout","extra_param":"steve"}']
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -60,6 +60,10 @@ describe OAuth2::Strategy::WebServer do
|
|
60
60
|
it 'returns AccessToken with #expires_at' do
|
61
61
|
@access.expires_at.should be_kind_of(Time)
|
62
62
|
end
|
63
|
+
|
64
|
+
it 'returns AccessToken with params accessible via []' do
|
65
|
+
@access['extra_param'].should == 'steve'
|
66
|
+
end
|
63
67
|
end
|
64
68
|
end
|
65
69
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 27
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Michael Bleigh
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date:
|
17
|
+
date: 2011-01-12 00:00:00 -06:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ~>
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 11
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
- 5
|
@@ -42,7 +40,6 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ~>
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 23
|
46
43
|
segments:
|
47
44
|
- 0
|
48
45
|
- 0
|
@@ -58,7 +55,6 @@ dependencies:
|
|
58
55
|
requirements:
|
59
56
|
- - ~>
|
60
57
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 11
|
62
58
|
segments:
|
63
59
|
- 1
|
64
60
|
- 4
|
@@ -74,7 +70,6 @@ dependencies:
|
|
74
70
|
requirements:
|
75
71
|
- - ~>
|
76
72
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 27
|
78
73
|
segments:
|
79
74
|
- 0
|
80
75
|
- 8
|
@@ -89,7 +84,6 @@ dependencies:
|
|
89
84
|
requirements:
|
90
85
|
- - ~>
|
91
86
|
- !ruby/object:Gem::Version
|
92
|
-
hash: 25
|
93
87
|
segments:
|
94
88
|
- 0
|
95
89
|
- 9
|
@@ -104,11 +98,11 @@ dependencies:
|
|
104
98
|
requirements:
|
105
99
|
- - ~>
|
106
100
|
- !ruby/object:Gem::Version
|
107
|
-
hash: 3
|
108
101
|
segments:
|
109
102
|
- 2
|
103
|
+
- 4
|
110
104
|
- 0
|
111
|
-
version:
|
105
|
+
version: 2.4.0
|
112
106
|
type: :development
|
113
107
|
version_requirements: *id006
|
114
108
|
description: A Ruby wrapper for the OAuth 2.0 protocol built with a similar style to the original OAuth gem.
|
@@ -158,7 +152,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
152
|
requirements:
|
159
153
|
- - ">="
|
160
154
|
- !ruby/object:Gem::Version
|
161
|
-
hash: 3
|
162
155
|
segments:
|
163
156
|
- 0
|
164
157
|
version: "0"
|
@@ -167,7 +160,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
160
|
requirements:
|
168
161
|
- - ">="
|
169
162
|
- !ruby/object:Gem::Version
|
170
|
-
hash: 23
|
171
163
|
segments:
|
172
164
|
- 1
|
173
165
|
- 3
|
@@ -175,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
167
|
version: 1.3.6
|
176
168
|
requirements: []
|
177
169
|
|
178
|
-
rubyforge_project:
|
170
|
+
rubyforge_project: oauth2
|
179
171
|
rubygems_version: 1.3.7
|
180
172
|
signing_key:
|
181
173
|
specification_version: 3
|