Web Connection
AddHeader - Authorization
HI Rick,
How do I code this, do I use AppendHeader?
var sha256 = require('sha256');
var seed = "abcdefghijklmnop"
var apikey = "_V87Qtb513Cd3vabM7RC0TbtJWeSo8p7"
var apipin = "123456"
var prehash = apikey + seed + apipin;
var apihash = 's2/'+ seed + '/' + sha256(prehash);
var authKey = new Buffer(apikey + ":" + apihash).toString('base64')
console.log("Authorization: Basic " + authKey);
ocodeit = CREATEOBJECT('wwencryption')
lcseed = "321456789012345678901234567890"
lcapikey = "<mykey>"
lcapipin = "<mypin>"
lcprehash = lcapikey + lcseed + lcapipin
lccoded = ocodeit.ComputeHash(lcprehash,"HMACSHA256",lcseed)
lcapihash = 's2/' + lcseed + '/' + lccoded
oHTTP.AppendHeader("x-custom","Custom Header")
oHTTP.AppendHeader("Authorization",lcapihash)
Thanks, Joy
HI Rick,
Basically my confusion on building this is the sha256()
var apihash = 's2/'+ seed + '/' + sha256(prehash);
var authKey = base64Encode(apikey + ':' + apihash)
In your class wwencryption, provide the equivalent with ComputeHash? set classlib to wwencryption otest = createobject("wwencryption") ? otest.ComputeHash(prehash, "SHA256", seed)
Second question: what about the equivalent of base64Encode? Is that the same as Strconv(apikey + ':' + apihash,13)?
Thanks, Joy