lib/square/api/o_auth_api.rb
# Returns an OAuth access token.
# The endpoint supports distinct methods of obtaining OAuth access tokens.
# Applications specify a method by adding the `grant_type` parameter
# in the request and also provide relevant information.
# __Note:__ Regardless of the method application specified,
# the endpoint always returns two items; an OAuth access token and
# a refresh token in the response.
# __OAuth tokens should only live on secure servers. Application clients
# should never interact directly with OAuth tokens__.
# @param [ObtainTokenRequest] body Required parameter: An object containing
# the fields to POST for the request.  See the corresponding object
# definition for field details.
# @return [ObtainTokenResponse Hash] response from the API call
Returns an OAuth access token.
The endpoint supports distinct methods of obtaining OAuth access tokens.
Applications specify a method by adding the `grant_type` parameter
in the request and also provide relevant information.
Note:__ Regardless of the method application specified,
the endpoint always returns two items; an OAuth access token and
a refresh token in the response.
OAuth tokens should only live on secure servers. Application clients
should never interact directly with OAuth tokens__.
Returns an OAuth access token . The endpoint supports distinct methods of obtaining OAuth access tokens . Applications specify a method by adding the ` grant_type ` parameter in the request and also provide relevant information . Note : __ Regardless of the method application specified the endpoint always returns two items ; an OAuth access token and a refresh token in the response . OAuth tokens should only live on secure servers . Application clients should never interact directly with OAuth tokens__ .
def obtain_token(body:)
      _query_builder = config.get_base_uri
      _query_builder << '/oauth2/token'
      _query_url = APIHelper.clean_url _query_builder
      _headers = {
        'accept' => 'application/json',
        'content-type' => 'application/json; charset=utf-8'
      }
      _request = config.http_client.post(
        _query_url,
        headers: _headers,
        parameters: body.to_json
      )
      _response = execute_request(_request)
      decoded = APIHelper.json_deserialize(_response.raw_body)
      _errors = APIHelper.map_response(decoded, ['errors'])
      ApiResponse.new(
        _response, data: decoded, errors: _errors
      )
    end
def obtain_token ( body : ) _query_builder = config . get_base_uri _query_builder << '/oauth2/token' _query_url = APIHelper . clean_url _query_builder _headers = { 'accept' => 'application/json' , 'content-type' => 'application/json; charset=utf-8' } _request = config . http_client . post ( _query_url , headers : _headers , parameters : body . to_json ) _response = execute_request ( _request ) decoded = APIHelper . json_deserialize ( _response . raw_body ) _errors = APIHelper . map_response ( decoded , [ 'errors' ] ) ApiResponse . new ( _response , data : decoded , errors : _errors ) end
Returns an OAuth access token.
Returns an OAuth access token .
# Prepare query url. # Prepare headers. # Prepare and execute HttpRequest. # Return appropriate response type.
response from the API call
response from the API call
ObtainTokenResponse Hash
body
<not_specific>
<not_specific>
body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.
body Required parameter : An object containing the fields to POST for the request . See the corresponding object definition for field details .