I like to grab the ClientBeginRequest and convert that to UNIX epoch time in the Fiddler scripts, however, I cant seem to get the known methods to work like Math.floor.
var iat = oSession.Timers.ClientBeginRequest; -> this does not give me unix time in sec
The idea is to generate json data with iat, exp and convert it to base64 and add it to the header
{
// Take ClientBeginRequest and convert it to unix
// var iat = oSession.Timers.ClientBeginRequest;
// var iat2 = Math.floor(iat / 1000);
// Take the // Take ClientBeginRequest and convert it to unix + 30 mins
// var exp = new Date(iat + minutesToAdd*60000);
// convert json data to base64
// var obj = {iat: 'iat', exp: 'exp'};
// objJsonStr = JSON.stringify(obj);
// objJsonB64 = Buffer.from(objJsonStr).toString("base64");
//Add the value to header
oSession.oRequest["new-header-name"] = "headerValue in base64";
}
Update:
I have iat and exp working, just need some help with converting the value to base64.
import Microsoft.JScript; var iat = Math.round((new Date()).getTime() / 1000); oSession.oRequest["iat"] = iat var exp = (iat + 1800); oSession.oRequest["exp"] = exp var data = {iat: 'iat', exp: 'exp'};
Check the following threads for more information on how to handle JSON and Base64 in FIddlerScript
https://www.telerik.com/forums/how-to-use-fiddler-webformats-json-jsondecode
https://www.telerik.com/forums/getting-responsebody-as-base64-string