Skip to content

Commit

Permalink
Can now modify the token parameter on the access token. Leaving it as…
Browse files Browse the repository at this point in the history
… by default because that's most commonly used.
  • Loading branch information
Michael Bleigh committed Jan 12, 2011
1 parent b29234f commit 607af1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
oauth2 (0.1.0)
oauth2 (0.1.1)
faraday (~> 0.5.0)
multi_json (~> 0.0.4)

Expand Down
6 changes: 5 additions & 1 deletion lib/oauth2/access_token.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module OAuth2
class AccessToken
attr_reader :client, :token, :refresh_token, :expires_in, :expires_at
attr_accessor :token_param

def initialize(client, token, refresh_token = nil, expires_in = nil, params = {})
@client = client
Expand All @@ -9,6 +10,7 @@ def initialize(client, token, refresh_token = nil, expires_in = nil, params = {}
@expires_in = (expires_in.nil? || expires_in == '') ? nil : expires_in.to_i
@expires_at = Time.now + @expires_in if @expires_in
@params = params
@token_param = 'access_token'
end

def [](key)
Expand All @@ -21,7 +23,9 @@ def expires?
end

def request(verb, path, params = {}, headers = {})
@client.request(verb, path, params.merge('access_token' => @token), headers.merge('Authorization' => "Token token=\"#{@token}\""))
params = params.merge token_param => @token
headers = headers.merge 'Authorization' => "OAuth #{@token}"

This comment has been minimized.

Copy link
@scott-steadman

scott-steadman Jan 28, 2011

Shouldn't this be ... => 'Token token="{@token}"" to match the code you took out?

This comment has been minimized.

Copy link
@mbleigh

mbleigh Jan 28, 2011

Contributor

Actually no, the spec changed such that the token= is no longer part of the header.

This comment has been minimized.

Copy link
@scott-steadman

scott-steadman Jan 28, 2011

Good to know! Thanks!

@client.request(verb, path, params, headers)
end

def get(path, params = {}, headers = {})
Expand Down

0 comments on commit 607af1c

Please sign in to comment.