Integrating NPM package "Authenticator" with postman for MFA

Hi Folks,
I need to integrate an external npm package “authenticator - npm” into Postman for cracking MFA.

Can anyone help me to solve this issue?

1 Like

You can’t utilise node libraries in Postman web or the desktop client.

You are limited to the libraries\modules built into the sandbox.

You can however use Newman as an node.JS module.

newman - npm (npmjs.com)

Or just turn off MFA on the account you use for testing, which is an common approach for this problem in automation as you aren’t usually testing the MFA element, but the application you hit after this.

Hey @anil1905 :waving_hand:

I know it’s been a while but I wanted to add this here for anyone else finding this thread.

That package can now be used in the Postman scripts:

const authenticator = pm.require('npm:[email protected]');

var formattedKey = authenticator.generateKey();
// "acqo ua72 d3yf a4e5 uorx ztkh j2xl 3wiz"
 
var formattedToken = authenticator.generateToken(formattedKey);
// "957 124"
 
authenticator.verifyToken(formattedKey, formattedToken);
// { delta: 0 }
 
authenticator.verifyToken(formattedKey, '000 000');
// null
 
authenticator.generateTotpUri(formattedKey, "[email protected]", "ACME Co", 'SHA1', 6, 30);

4 Likes