-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Can now modify the token parameter on the access token. Leaving it as…
… by default because that's most commonly used.
- Loading branch information
Michael Bleigh
committed
Jan 12, 2011
1 parent
b29234f
commit 607af1c
Showing
2 changed files
with
6 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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) | ||
|
@@ -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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mbleigh
Contributor
|
||
@client.request(verb, path, params, headers) | ||
end | ||
|
||
def get(path, params = {}, headers = {}) | ||
|
Shouldn't this be ... => 'Token token="{@token}"" to match the code you took out?