AnsweredAssumed Answered

Insert from URL and Javascript

Question asked by twelvetens on Nov 26, 2015
Latest reply on Nov 30, 2015 by twelvetens



I'm just trying to get my head around something that's probably pretty simple for those in the know.


I'm trying to run some javascript using the Insert From URL script step, to return a signature for an API authorisation request.


The javascript is:


<script src=""></script>
<script src=""></script>
<script type="text/javascript">

   function CalculateSig(stringToSign, privateKey){
   var hash = CryptoJS.HmacSHA1(stringToSign, privateKey);
   var base64 = hash.toString(CryptoJS.enc.Base64);
   return encodeURIComponent(base64);

   var d = new Date,
  expiration = 3600 // 1 hour,
  unixtime = parseInt(d.getTime() / 1000),
  future_unixtime = unixtime + expiration,
  publicKey = "1234",
  privateKey = "abcd",
  method = "GET",
  route = "forms/1/entries";

  stringToSign = publicKey + ":" + method + ":" + route + ":" + future_unixtime;
  sig = CalculateSig(stringToSign, privateKey);

... which is all pulled from the Gravity Forms Web API documentation....


I'd like to get the above to return the singature for the API session when I enter in my public and private key. Is this even possible? Am I barking up the wrong tree? I was hoping I could use InsertFromURL to populate a field with the result, which would be the signature...