John6122514
Posts: 0
Joined: Wed Aug 07, 2013 7:10 pm

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Generate dynamic signature using SHA256

Hi John,

Appery.io doesn't support Ruby, you can use JS. Try: http://www.webtoolkit.info/javascript... or http://www.bichlmeier.info/sha256.html

Dev
Posts: 0
Joined: Mon Jan 27, 2014 1:08 pm

Generate dynamic signature using SHA256

Katya

would you provide some examples with JS?

Return to “Issues”