Generate dynamic signature using SHA256
I am creating a RestAPI service and I am running into an issue that I am unable to figure out the in Appery system. Every request must be hashed using HMAC-SHA256 using the secret obtained from the API provider.
I need this to happen dynamically with every request. I know if works if I put the correct signature and token in the header for a particular string. I just need to create an extra step that will change the signature based on the URL string.
Here is how it would be done in Ruby:
require 'base64'
require 'openssl'
secret = "xyz"
request = "GET api.URL.com/endpoint?page=1&per_page=1"
digest = OpenSSL::Digest::Digest.new('sha256')
signature = Base64.encode64(OpenSSL::HMAC.digest(digest, secret, request)).chomp