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

Two party authentication #16

Closed
famewolf opened this issue Jan 26, 2019 · 12 comments
Closed

Two party authentication #16

famewolf opened this issue Jan 26, 2019 · 12 comments
Assignees
Labels
enhancement New feature or request

Comments

@famewolf
Copy link

I need to enter the 6 digit code for two party authentication into chrome. Once it's in, it will be ok for 30 days....I just can't figure out where chrome is or how to get the script to pause so I can fill the page out.

Point me in the right direction?

@jpchip
Copy link
Owner

jpchip commented Jan 29, 2019

When you start the script, a new chrome instance/window should open where everything happens.

@famewolf
Copy link
Author

famewolf commented Jan 29, 2019 via email

@jpchip
Copy link
Owner

jpchip commented Jan 29, 2019

Ah yeah, you'll have to tweak the code slightly to give you time to enter your code. In index.js, something like:

//sign in
await signIn(page, username, password);

//wait here until user submits two factor auth code
const twoFactorAuthPromise = page.waitForNavigation();
await twoFactorAuthPromise;

//go to giveaways

I haven't tried that, but I'm pretty sure that would do it.

@famewolf
Copy link
Author

famewolf commented Feb 3, 2019

Tried the code...it sat on the giveaway page....terminal showed:

famewolf@hp810-135qe ~/giveaway-grabber $ npm start

giveaway-grabber@1.0.1 start /home/famewolf/giveaway-grabber
node index.js

Page 1 Start:
giveaway 1 did not exist?
giveaway 2 did not exist?
giveaway 3 did not exist?
giveaway 4 did not exist?
giveaway 5 did not exist?
giveaway 6 did not exist?
giveaway 7 did not exist?
giveaway 8 did not exist?
giveaway 9 did not exist?
giveaway 10 did not exist?
giveaway 11 did not exist?
giveaway 12 did not exist?
giveaway 13 did not exist?
giveaway 14 did not exist?
giveaway 15 did not exist?
giveaway 16 did not exist?
giveaway 17 did not exist?
giveaway 18 did not exist?
giveaway 19 did not exist?
giveaway 20 did not exist?
giveaway 21 did not exist?
giveaway 22 did not exist?
giveaway 23 did not exist?
giveaway 24 did not exist?
No more pages! Goodbye!

There were plenty there.

     //sign in
    await signIn(page, username, password);

    //wait here until user submits two factor auth code
    const twoFactorAuthPromise = page.waitForNavigation();
    await twoFactorAuthPromise;

    //go to giveaways
    let url = 'https://www.amazon.com/ga/giveaways';
    if (args.page) {

@jpchip
Copy link
Owner

jpchip commented Feb 4, 2019

See comment: #15 (comment)

@jpchip
Copy link
Owner

jpchip commented Feb 5, 2019

@famewolf Just published fix for #15, give this another try and let me know if you are still have problems.

I should think about adding this change as under a flag so everyone can use two factor auth if they want....

@famewolf
Copy link
Author

famewolf commented Feb 5, 2019

It works however initially it crashed because I took to long to enter the code....the average user is going to need time to grab their phone..open the app..enter their pin and then enter the code so you may need to adjust the delay if you make this a feature. Really nice! You'd also want to check the "Don't ask for 30 days" checkbox on the 2 party screen.

*original error before I tried 2nd time:

giveaway-grabber@2.0.0 start /home/famewolf/giveaway-grabber
node index.js

(node:9936) UnhandledPromiseRejectionWarning: TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
at Promise.then (/home/famewolf/giveaway-grabber/node_modules/puppeteer/lib/FrameManager.js:1276:21)
at
-- ASYNC --
at Frame. (/home/famewolf/giveaway-grabber/node_modules/puppeteer/lib/helper.js:144:27)
at Page.waitForNavigation (/home/famewolf/giveaway-grabber/node_modules/puppeteer/lib/Page.js:644:49)
at Page. (/home/famewolf/giveaway-grabber/node_modules/puppeteer/lib/helper.js:145:23)
at /home/famewolf/giveaway-grabber/index.js:28:40
at
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:9936) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9936) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@jpchip
Copy link
Owner

jpchip commented Feb 5, 2019

Thanks. I'll create a new ticket for adding this feature. I think you can increase the default timeout like:

 const twoFactorAuthPromise = page.waitForNavigation({ timeout: 60000 }); //60 seconds instead of 30

@jpchip jpchip self-assigned this Feb 5, 2019
@jpchip jpchip added the enhancement New feature or request label Feb 5, 2019
@jpchip
Copy link
Owner

jpchip commented Feb 12, 2019

Just published new release with optional support for two factor authentication (see readme).

@jpchip jpchip closed this as completed Feb 12, 2019
@famewolf
Copy link
Author

Working great "as we speak" although the "npm -- -2fa" is a little awkward. I'll stick it in an alias and be good to go. Thank you!

@famewolf
Copy link
Author

Have you considered adding these as additional entries to .env vs command line parms?
User=blah
Password=blah
2FA=Yes
KINDLE=No

@jpchip
Copy link
Owner

jpchip commented Feb 13, 2019

user and password are already in the .env file, see the .env.example. I guess I could add the 2FA one as well, I was just lazy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants