class MisocaRubyClient::Client
Constants
- MISOCA_AUTHORIZE_URI
- MISOCA_END_POINT
- MISOCA_TOKEN_URI
Attributes
access_token[R]
Public Class Methods
new(application_id, secret, callback_url, config_block = nil)
click to toggle source
# File lib/misoca_ruby_client/client.rb, line 10 def initialize(application_id, secret, callback_url, config_block = nil) @application_id = application_id @secret = secret @client = OAuth2::Client.new(@application_id, @secret, site: MISOCA_END_POINT, authorize_url: MISOCA_AUTHORIZE_URI, token_url: MISOCA_TOKEN_URI) @callback_url = callback_url @config_block = config_block @access_token = nil end
Public Instance Methods
exchange_token(code)
click to toggle source
# File lib/misoca_ruby_client/client.rb, line 23 def exchange_token(code) @access_token = @client.auth_code.get_token(code, :redirect_uri => @callback_url) @config_block.call(@access_token) if @config_block end
inject_access_token(access_token, refresh_token)
click to toggle source
# File lib/misoca_ruby_client/client.rb, line 33 def inject_access_token(access_token, refresh_token) @access_token = OAuth2::AccessToken.new(@client, access_token, refresh_token: refresh_token) end
refresh_access_token()
click to toggle source
# File lib/misoca_ruby_client/client.rb, line 28 def refresh_access_token @access_token = @access_token.refresh! @config_block.call(@access_token) if @config_block end