Skip to content

Commit

Permalink
Add callback_uri to get_access_token, which uses WePay's /oauth2/toke…
Browse files Browse the repository at this point in the history
…n API. The callback_uri is used to receive IPNs when the user revokes an access_token or is deleted.
  • Loading branch information
jules27 committed Apr 11, 2013
1 parent 4dc9c39 commit e80b3e2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/wepay-rails.rb
Expand Up @@ -144,12 +144,14 @@ def call_api(api_path, params={}, timeout=30000)
end

# Fetch the access token from wepay for the auth code
def get_access_token(auth_code, redirect_uri)
def get_access_token(auth_code, redirect_uri, callback_uri = nil)
params = {
:client_id => @wepay_config[:client_id],
:client_secret => @wepay_config[:client_secret],
:redirect_uri => redirect_uri,
:code => auth_code
:code => auth_code,
:callback_uri => callback_uri # Optional field in which you will receive IPNs with the user_id
# when the user revokes an access_token or is deleted.
}
json = call_api("/oauth2/token", params)
raise WepayRails::Exceptions::AccessTokenError.new("A problem occurred trying to get the access token: #{json.inspect}") unless json.has_key?(:access_token)
Expand Down

0 comments on commit e80b3e2

Please sign in to comment.