1

I'm experiencing an issue where in once execute end point is being run, It returns an error name: 'JsonWebTokenError', message: 'jwt malformed', I already have an environment variable using the JWT Signing Secret of my installed package.

This is a sample JWT Signing Secret

75VNnlc3AeYUX3whWaHk6ApJsBM19p6ZK_ZMXbK7c2GwWxyMcMxnxDVZGarJSNCc7P6ZTAaLaq7droBNIhchXZmx9X9hCKDDB6Gd5rOmzmg5DT_U1KzCMGxrmR2B6Pfwr_VMENNhEeyRgVVO7jPKd-q-Gp70rhcUKlE8CoCttAmtu8QM8brK8KW5Q9t1z9VSSeJp6dNvV6GKO83LQQfXlMP6ApHPR7SUWtm3KFdq1Larah7QtfLgnuziXZpGXA2

This is my

Execute method

exports.execute = function (req, res) {//console.log("execute function!!!");


console.log("EXECUTE HAS BEEN RUN");
console.log('KEY - > ' + process.env.JWT_KEY);
JWT(req.body, process.env.JWT_KEY, (err, decoded) => {

    // verification error -> unauthorized request
    if (err) {
        console.error(err);
        return res.status(401).end();
    }


    if (decoded && decoded.inArguments && decoded.inArguments.length > 0) {
        console.log('##### decoded ####=>', decoded);

        // decoded in arguments

    } else {
        console.error('inArguments invalid.');
        return res.status(400).end();
    }

});
console.log("end execute function!!!");

};

 This is my Decoder

    'use strict';

module.exports = (body, secret, cb) => {
    if (!body) {
        return cb(new Error('invalid jwtdata'));
    }

    require('jsonwebtoken').verify(body.toString('utf8'), secret, {
        algorithm: 'HS256'
    }, cb);
};

btw I'm using azure as a host for my web app.

Blockquote

Another question for my config.json is it allright if I don't have any inArguments since I can get the value from the incoming data associated with the entry event

1

1) Try to add body parser to your express server:

const app = express();
app.use(require('body-parser').raw({
   type: 'application/jwt'
}));

2) Regarding getting data from entry event source check my answer here: Get the name of the Data Extension you are working with : Custom Activity

  • Thanks! @RosHaitovich – imajmdf Sep 23 '19 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.