I am trying to sign a message which is sent as a payload for authentication. This message consists of a nonce, plus the unsigned and the signed message, including the api key which the other party should use to authenticate me.
I am using the following,
pack.setUserAuthentication({
type: coda.AuthenticationType.Custom,
params: [
{ name: "api_key", description: "API key." },
{ name: "api_secret", description: "API secret." },
],
});
I then get these values on addFormula like so
pack.addFormula({
...
execute: async function ([from, to, text], context) {
// Create the placeholders for the API key and secret.
let invocationToken = context.invocationToken;
let apiKeyPlaceholder = "{{api_key-" + invocationToken + "}}";
let apiSecretPlaceholder = "{{api_secret-" + invocationToken + "}}";
// Do signing of a message with "crypto" library or CryptoJS
...
// Do request
I can CLEARLY see that the placeholders are not being replaced which causes the token to be incorrect. I have corroborated that my signing function works (when hardcoding the secret and api key).
I know this might be because these placeholders are probably switched only inside the scope of fetch
, but is there another way I can sign tokens?
All help is totally appreciated