oauth2 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/VERSION +1 -1
- data/lib/oauth2/access_token.rb +4 -3
- data/lib/oauth2/strategy/web_server.rb +5 -4
- data/oauth2.gemspec +1 -1
- data/spec/oauth2/strategy/web_server_spec.rb +7 -3
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/lib/oauth2/access_token.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module OAuth2
|
2
2
|
class AccessToken
|
3
|
-
attr_reader :client, :token
|
3
|
+
attr_reader :client, :token, :refresh_token
|
4
4
|
|
5
|
-
def initialize(client, token)
|
5
|
+
def initialize(client, token, refresh_token = nil)
|
6
6
|
@client = client
|
7
7
|
@token = token
|
8
|
+
@refresh_token = refresh_token
|
8
9
|
end
|
9
10
|
|
10
11
|
def request(verb, path, params = {}, headers = {})
|
@@ -27,4 +28,4 @@ module OAuth2
|
|
27
28
|
request(:delete, path, params, headers)
|
28
29
|
end
|
29
30
|
end
|
30
|
-
end
|
31
|
+
end
|
@@ -10,10 +10,11 @@ module OAuth2
|
|
10
10
|
# in order to successfully verify your request for most OAuth 2.0
|
11
11
|
# endpoints.
|
12
12
|
def get_access_token(code, options = {})
|
13
|
-
response = @client.request(:
|
13
|
+
response = @client.request(:post, @client.access_token_url, access_token_params(code, options))
|
14
14
|
params = Rack::Utils.parse_query(response)
|
15
|
-
|
16
|
-
|
15
|
+
access = params['access_token']
|
16
|
+
refresh = params['refresh_token']
|
17
|
+
OAuth2::AccessToken.new(@client, access, refresh)
|
17
18
|
end
|
18
19
|
|
19
20
|
# <b>DEPRECATED:</b> Use #get_access_token instead.
|
@@ -30,4 +31,4 @@ module OAuth2
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
33
|
-
end
|
34
|
+
end
|
data/oauth2.gemspec
CHANGED
@@ -5,8 +5,8 @@ describe OAuth2::Strategy::WebServer do
|
|
5
5
|
cli = OAuth2::Client.new('abc','def', :site => 'http://api.example.com')
|
6
6
|
cli.connection.build do |b|
|
7
7
|
b.adapter :test do |stub|
|
8
|
-
stub.
|
9
|
-
[200, {}, 'a=1&access_token=salmon']
|
8
|
+
stub.post('/oauth/access_token') do |env|
|
9
|
+
[200, {}, 'a=1&access_token=salmon&refresh_token=trout']
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -41,5 +41,9 @@ describe OAuth2::Strategy::WebServer do
|
|
41
41
|
it 'returns AccessToken with #token' do
|
42
42
|
@access.token.should == 'salmon'
|
43
43
|
end
|
44
|
+
|
45
|
+
it 'returns AccessToken with #refresh_token' do
|
46
|
+
@access.refresh_token.should == 'trout'
|
47
|
+
end
|
44
48
|
end
|
45
|
-
end
|
49
|
+
end
|