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

Error with otp in scrape example #2483

Closed
nettrino opened this issue Sep 29, 2022 · 4 comments
Closed

Error with otp in scrape example #2483

nettrino opened this issue Sep 29, 2022 · 4 comments

Comments

@nettrino
Copy link
Contributor

nettrino commented Sep 29, 2022

Hello,

I am trying to replicate the scrape example and if I use the OTP from an authenticator app (Google, Authy or otherwise) I get panic: decode secret failed, and if I use my yubikey I get received 422 response submitting otp form. Anything I am missing on how otp should be passed?

Thanks!

@gmlewis
Copy link
Collaborator

gmlewis commented Oct 1, 2022

Sorry, I am not very familiar with the scrape example. Hopefully someone else with more experience can comment on this issue.

@nettrino
Copy link
Contributor Author

nettrino commented Oct 4, 2022

Thanks @gmlewis. I've created a wrapper using rsc.io/2fa as a temporary quickfix (some of the classes in scraping are outdated anyhow due to selectors having changed (e.g., .oath-application-allowlist instead of whitelist) so I had to make changes to the scrape package anyhow). The process for registering the token was to run go install rsc.io/2fa@latest and then register github using 2fa -add github. Subsequently, in the github 2fa settings, instead of scanning the QR code, select the "text key" option, and paste that to the CLI. From that point on, 2fa github should give you an OTP. I modified the Authenticate function to patch the otp part directly passing the output from 2fa:

	setOTP := func(values url.Values) {
		values.Set("otp", otpcode)
	}

Hopefully the above is useful, I can try and make a PR if you think the above flow makes sense, however waiting for someone else from the maintainers to comment on this.

@nettrino
Copy link
Contributor Author

nettrino commented Oct 7, 2022

@gmlewis the code in the repo for the login part works fine. We don't need to register a separate 2fa as I mentioned in my previous comment all we need to do is when subscribing to github, before scanning the QR code select the text key option, and then get the secret key and pass that as an input for the OTP seed if that makes sense. Thus we would scan the QR code via the app, and use the secret key to bootstrap the OTP for any CLI use. Don't know why I had gotten confused previously about this as its actually in the comments in the code

@nettrino nettrino closed this as completed Oct 7, 2022
@nettrino
Copy link
Contributor Author

nettrino commented Oct 7, 2022

@gmlewis opened #2488 to address the outdated selector issue

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

2 participants