Sha256: 98b4518b40cf50e716279d5f3f4ca574a398b0a57485ce28b5188598be146046
Contents?: true
Size: 1.18 KB
Versions: 4
Compression:
Stored size: 1.18 KB
Contents
module Finnegans module Core module Authentication AUTH_PATH = '/oauth/token'.freeze private_constant :AUTH_PATH private def get_access_token request_params = { method: :get, params: auth_common_params.merge({grant_type: 'client_credentials'}) } auth_request(request_params) end def refresh_access_token request_params = { method: :get, params: auth_common_params.merge({ grant_type: 'refresh_token', refresh_token: @access_token }) } auth_request(request_params) end def auth_request(request_params) response = request_call(AUTH_PATH, request_params) body = json_load(response.body) response.success? ? body : (raise AuthenticationError.new(body), body['error']) end def auth_common_params { client_id: @client_id, client_secret: @client_secret } end def authenticated_param # For the Finnegan API the params are case sensitive and this should be in all caps { "ACCESS_TOKEN" => @access_token } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems