Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git://github.com/jeremy/oauth2

  • Loading branch information...
commit 9650cea68f6991ee32bea1d934061b51fb461390 2 parents c5f6d0e + b8a74e0
Michael Bleigh authored
View
7 lib/oauth2/access_token.rb
@@ -1,10 +1,11 @@
module OAuth2
class AccessToken
- attr_reader :client, :token
+ attr_reader :client, :token, :refresh_token
- def initialize(client, token)
+ def initialize(client, token, refresh_token = nil)
@client = client
@token = token
+ @refresh_token = refresh_token
end
def request(verb, path, params = {}, headers = {})
@@ -27,4 +28,4 @@ def delete(path, params = {}, headers = {})
request(:delete, path, params, headers)
end
end
-end
+end
View
9 lib/oauth2/strategy/web_server.rb
@@ -10,10 +10,11 @@ def authorize_params(options = {}) #:nodoc:
# in order to successfully verify your request for most OAuth 2.0
# endpoints.
def get_access_token(code, options = {})
- response = @client.request(:get, @client.access_token_url, access_token_params(code, options))
+ response = @client.request(:post, @client.access_token_url, access_token_params(code, options))
params = Rack::Utils.parse_query(response)
- token = params['access_token']
- OAuth2::AccessToken.new(@client, token)
+ access = params['access_token']
+ refresh = params['refresh_token']
+ OAuth2::AccessToken.new(@client, access, refresh)
end
# <b>DEPRECATED:</b> Use #get_access_token instead.
@@ -30,4 +31,4 @@ def access_token_params(code, options = {}) #:nodoc:
end
end
end
-end
+end
View
10 spec/oauth2/strategy/web_server_spec.rb
@@ -5,8 +5,8 @@
cli = OAuth2::Client.new('abc','def', :site => 'http://api.example.com')
cli.connection.build do |b|
b.adapter :test do |stub|
- stub.get('/oauth/access_token?code=sushi&client_id=abc&client_secret=def&type=web_server') do |env|
- [200, {}, 'a=1&access_token=salmon']
+ stub.post('/oauth/access_token?code=sushi&client_id=abc&client_secret=def&type=web_server') do |env|
+ [200, {}, 'a=1&access_token=salmon&refresh_token=trout']
end
end
end
@@ -41,5 +41,9 @@
it 'returns AccessToken with #token' do
@access.token.should == 'salmon'
end
+
+ it 'returns AccessToken with #refresh_token' do
+ @access.refresh_token.should == 'trout'
+ end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.