class CyberSource::OAuthApi
Attributes
Public Class Methods
# File lib/cybersource_rest_client/api/o_auth_api.rb, line 19 def initialize(api_client = ApiClient.default, config) @api_client = api_client @api_client.set_configuration(config) end
Public Instance Methods
Create access token and refresh token This request is used by technology partners to obtain an access token and a refresh token, which are contained in the response. The partner can then use the access token for authentication when submitting API requests to CyberSource
on behalf of the merchant. The request must include the authorization code that was included in the URL redirect response from CyberSource
(see [full documentation](developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro.html)). Access tokens expire after 15 minutes. The refresh token is used to create a new access token, it expires after one year. @param create_access_token_request Request payload @param [Hash] opts the optional parameters @option opts [String] :v_c_client_correlation_id We recommended that you submit this header with a unique value in every client request to this endpoint. It is sent back in the response header and logged both in the request log and response log. @return [AccessTokenResponse]
# File lib/cybersource_rest_client/api/o_auth_api.rb, line 29 def create_access_token(create_access_token_request, opts = {}) data, status_code, headers = create_access_token_with_http_info(create_access_token_request, opts) return data, status_code, headers end
Create access token and refresh token This request is used by technology partners to obtain an access token and a refresh token, which are contained in the response. The partner can then use the access token for authentication when submitting API requests to CyberSource
on behalf of the merchant. The request must include the authorization code that was included in the URL redirect response from CyberSource
(see [full documentation](developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro.html)). Access tokens expire after 15 minutes. The refresh token is used to create a new access token, it expires after one year. @param create_access_token_request Request payload @param [Hash] opts the optional parameters @option opts [String] :v_c_client_correlation_id We recommended that you submit this header with a unique value in every client request to this endpoint. It is sent back in the response header and logged both in the request log and response log. @return [Array<(AccessTokenResponse
, Fixnum, Hash)>] AccessTokenResponse
data, response status code and response headers
# File lib/cybersource_rest_client/api/o_auth_api.rb, line 40 def create_access_token_with_http_info(create_access_token_request, opts = {}) if @api_client.config.debugging begin raise @api_client.config.logger.debug 'Calling API: OAuthApi.create_access_token ...' rescue puts 'Cannot write to log' end end # verify the required parameter 'create_access_token_request' is set if @api_client.config.client_side_validation && create_access_token_request.nil? fail ArgumentError, "Missing the required parameter 'create_access_token_request' when calling OAuthApi.create_access_token" end if @api_client.config.client_side_validation && !opts[:'v_c_client_correlation_id'].nil? && opts[:'v_c_client_correlation_id'].to_s.length > 36 fail ArgumentError, 'invalid value for "opts[:"v_c_client_correlation_id"]" when calling OAuthApi.create_access_token, the character length must be smaller than or equal to 36.' end if @api_client.config.client_side_validation && !opts[:'v_c_client_correlation_id'].nil? && opts[:'v_c_client_correlation_id'].to_s.length < 36 fail ArgumentError, 'invalid value for "opts[:"v_c_client_correlation_id"]" when calling OAuthApi.create_access_token, the character length must be great than or equal to 36.' end #if @api_client.config.client_side_validation && !opts[:'v_c_client_correlation_id'].nil? && opts[:'v_c_client_correlation_id'] !~ Regexp.new(/^[A-Za-z0-9\\.\\-_:]+$/) #fail ArgumentError, "invalid value for 'opts[:\"v_c_client_correlation_id\"]' when calling OAuthApi.create_access_token, must conform to the pattern /^[A-Za-z0-9\\.\\-_:]+$/." #end # resource path local_var_path = 'oauth2/v3/token' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=utf-8']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) header_params[:'v-c-client-correlation-id'] = opts[:'v_c_client_correlation_id'] if !opts[:'v_c_client_correlation_id'].nil? # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(create_access_token_request) auth_names = [] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'AccessTokenResponse') if @api_client.config.debugging begin raise @api_client.config.logger.debug "API called: OAuthApi#create_access_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" rescue puts 'Cannot write to log' end end return data, status_code, headers end