Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newbie question - how to create an otpFn that isn't skipped over? #20

Open
klauern opened this issue Jan 4, 2022 · 0 comments
Open

Comments

@klauern
Copy link

klauern commented Jan 4, 2022

Hello!

This might be a newbie question, but I am attempting to create an otpFn to prompt for the MFA code, and it seems to keep returning early:

(async () => {
  const api = new AmazonOrderReportsApi({
    logLevel: LogLevel.DEBUG,
    username: '[email protected]',
    password: 'pass',
    otpFn: async () => {
      let answer = '';
      const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout,
      });
      await rl.question('what is otp Code? ', (ans) => {
        answer = ans;
      });
      return answer;
    },
  });
  ... // rest omitted

What I get though is this in the log. It doesn't even wait for the prompt:

{"level":"debug","message":"Entering OTP code","metadata":{},"timestamp":"2022-01-04T01:36:36.285Z"}
what is otp Code? {"level":"debug","message":"nick remember device input","metadata":{},"timestamp":"2022-01-04T01:36:36.290Z"}
{"level":"debug","message":"Clicking input[type=submit]","metadata":{},"timestamp":"2022-01-04T01:36:36.309Z"}
{"level":"debug","message":"Account fixup","metadata":{},"timestamp":"2022-01-04T01:36:36.897Z"}
/Users/klauern/dev/js-ts/amazon-order-reports-api/lib/index.js:198
            throw new Error(message ?? `Assertion failed! No element matching selector: ${selector}`);
                  ^
Error: No sign-out link detected, failed to sign in?
... bunch of stacktrace
Waiting for the debugger to disconnect...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant