class TransferWise::OAuth
Attributes
access_token[RW]
Public Class Methods
new(client_id, client_secret)
click to toggle source
# File lib/transfer_wise/oauth.rb, line 5 def initialize(client_id, client_secret) @client_id, @client_secret = client_id, client_secret end
Public Instance Methods
client()
click to toggle source
Get the OAuth
2 client
# File lib/transfer_wise/oauth.rb, line 10 def client @client ||= ::OAuth2::Client.new( @client_id, @client_secret, { site: TransferWise.api_base, auth_scheme: :basic_auth } ) end
get_access_token(code, redirect_url)
click to toggle source
Get the access token. You must pass the exact same redirect_url passed to the authorize_url
method
# File lib/transfer_wise/oauth.rb, line 28 def get_access_token(code, redirect_url) @access_token ||= client.auth_code.get_token(code, redirect_uri: redirect_url) end
refresh_token(access_token, opts = {})
click to toggle source
This method is used to refresh the access token before it expires
# File lib/transfer_wise/oauth.rb, line 33 def refresh_token(access_token, opts = {}) OAuth2::AccessToken.new(client, access_token, opts).refresh! end