class Vend::Oauth2::AuthCode
Constants
- AUTHORIZE_URL
- DEFAULT_OPTIONS
- TOKEN_URL
Attributes
client_id[RW]
redirect_uri[RW]
secret[RW]
store[RW]
Public Class Methods
new(store, client_id, secret, redirect_uri, options = {})
click to toggle source
# File lib/vend/oauth2/auth_code.rb, line 12 def initialize(store, client_id, secret, redirect_uri, options = {}) @store = store @client_id = client_id @secret = secret @redirect_uri = redirect_uri @options = DEFAULT_OPTIONS.merge(options) end
Public Instance Methods
refresh_token(auth_token, refresh_token)
click to toggle source
# File lib/vend/oauth2/auth_code.rb, line 29 def refresh_token(auth_token, refresh_token) access_token = OAuth2::AccessToken.new(get_oauth2_client(store), auth_token, {refresh_token: refresh_token}) access_token.refresh! end
token_from_code(code)
click to toggle source
# File lib/vend/oauth2/auth_code.rb, line 24 def token_from_code(code) client = get_oauth2_client(store) client.auth_code.get_token(code, redirect_uri: redirect_uri) end
Protected Instance Methods
get_oauth2_client(domain_prefix = 'secure')
click to toggle source
# File lib/vend/oauth2/auth_code.rb, line 36 def get_oauth2_client(domain_prefix = 'secure') OAuth2::Client.new(client_id, secret, { site: "https://#{domain_prefix}.vendhq.com", authorize_url: AUTHORIZE_URL, token_url: TOKEN_URL }) end