lib/square/api/o_auth_api.rb
# Returns an OAuth access token and a refresh token unless the
# `short_lived` parameter is set to `true`, in which case the endpoint
# returns only an access token.
# The `grant_type` parameter specifies the type of OAuth request. If
# `grant_type` is `authorization_code`, you must include the authorization
# code you received when a seller granted you authorization. If `grant_type`
# is `refresh_token`, you must provide a valid refresh token. If you are
# using
# an old version of the Square APIs (prior to March 13, 2019), `grant_type`
# can be `migration_token` and you must provide a valid migration token.
# You can use the `scopes` parameter to limit the set of permissions granted
# to the access token and refresh token. You can use the `short_lived`
# parameter
# to create an access token that expires in 24 hours.
# __Note:__ OAuth tokens should be encrypted and stored on a secure server.
# 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 and a refresh token unless the
`short_lived` parameter is set to `true`, in which case the endpoint
returns only an access token.
The `grant_type` parameter specifies the type of OAuth request. If
`grant_type` is `authorization_code`, you must include the authorization
code you received when a seller granted you authorization. If `grant_type`
is `refresh_token`, you must provide a valid refresh token. If you are
using
an old version of the Square APIs (prior to March 13, 2019), `grant_type`
can be `migration_token` and you must provide a valid migration token.
You can use the `scopes` parameter to limit the set of permissions granted
to the access token and refresh token. You can use the `short_lived`
parameter
to create an access token that expires in 24 hours.
Note:__ OAuth tokens should be encrypted and stored on a secure server.
Application clients should never interact directly with OAuth tokens.
Returns an OAuth access token and a refresh token unless the ` short_lived ` parameter is set to ` true ` in which case the endpoint returns only an access token . The ` grant_type ` parameter specifies the type of OAuth request . If ` grant_type ` is ` authorization_code ` you must include the authorization code you received when a seller granted you authorization . If ` grant_type ` is ` refresh_token ` you must provide a valid refresh token . If you are using an old version of the Square APIs ( prior to March 13 2019 ) ` grant_type ` can be ` migration_token ` and you must provide a valid migration token . You can use the ` scopes ` parameter to limit the set of permissions granted to the access token and refresh token . You can use the ` short_lived ` parameter to create an access token that expires in 24 hours . Note : __ OAuth tokens should be encrypted and stored on a secure server . 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 and a refresh token unless the
`short_lived` parameter is set to `true`, in which case the endpoint
returns only an access token.
Returns an OAuth access token and a refresh token unless the ` short_lived ` parameter is set to ` true ` in which case the endpoint returns only an 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 .