# Creates the request signature for the specified data
# @param type [String] The type of request i.e. GET OR POST
# @param path [String] The path that this request is for
# @param timestamp [String] The iso8601 timestamp
# @param body [String] The request's body
# @return [String] The base64 encoded signature
def request_signature(type, path, timestamp, body)
body = body.downcase unless body.nil?
# Strip out any query parameters since they aren't used for
path = path.gsub(/\?.*$/, '')
s = "#{@token.downcase}\n#{type.downcase}\n#{path.downcase}\n#{body}\n#{timestamp.downcase}".force_encoding("utf-8")
Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), @key, s)).gsub(/\n/,'')
end
Have more questions? Submit a request
Comments
Please sign in to leave a comment.