Class: TqlOtrFactoringDataExchange::OauthAuthorizationApi
- Defined in:
- lib/tql_otr_factoring_data_exchange/apis/oauth_authorization_api.rb
Overview
OauthAuthorizationApi
Constant Summary
Constants inherited from BaseApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#request_token(authorization, scope: nil, _field_parameters: nil) ⇒ ApiResponse
Create a new OAuth 2 token.
Methods inherited from BaseApi
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from TqlOtrFactoringDataExchange::BaseApi
Instance Method Details
#request_token(authorization, scope: nil, _field_parameters: nil) ⇒ ApiResponse
Create a new OAuth 2 token. Basic auth format space-delimited list. supported by this endpoint.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tql_otr_factoring_data_exchange/apis/oauth_authorization_api.rb', line 17 def request_token(, scope: nil, _field_parameters: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/oauth2/token', Server::DEFAULT) .form_param(new_parameter('client_credentials', key: 'grant_type')) .header_param(new_parameter(, key: 'Authorization') .is_required(true)) .form_param(new_parameter(scope, key: 'scope')) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type')) .header_param(new_parameter('application/json', key: 'accept')) .additional_form_params(_field_parameters)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(OauthToken.method(:from_hash)) .is_api_response(true) .local_error('400', 'OAuth 2 provider returned an error.', OauthProviderException) .local_error('401', 'OAuth 2 provider says client authentication failed.', OauthProviderException)) .execute end |