Skip to content

feat: add TOTP 2FA support to session token generation#44

Merged
henrique-coder merged 3 commits into
prodfrom
feature/totp-2fa-support
May 23, 2026
Merged

feat: add TOTP 2FA support to session token generation#44
henrique-coder merged 3 commits into
prodfrom
feature/totp-2fa-support

Conversation

@henrique-coder
Copy link
Copy Markdown
Owner

This PR implements support for TOTP 2-Factor Authentication during the get_session_token flow.

It is heavily based on the initial work by @Villoh in #42, but was refactored to:

  • Handle modular email OTP verification properly
  • Support automatic retry loops for invalid or expired OTP codes
  • Support automatic retry loops for invalid TOTP codes
  • Avoid HTTP 400 crashes on format errors or wrong codes

Co-authored-by: Villoh villoh.github@gmail.com

Closes #42

henrique-coder and others added 2 commits May 22, 2026 23:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the perplexity-webui-scraper token interactive CLI flow to support Perplexity accounts that require TOTP-based 2FA during session token generation, updating the auth flow to detect and complete the additional challenge step.

Changes:

  • Refactors the get_session_token command into helper functions and adds TOTP challenge detection + verification loop.
  • Adds a new internal constant for the TOTP verification endpoint.
  • Updates user-facing docs (README, CHANGELOG) and bumps a lockfile dependency.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
uv.lock Updates locked dependency version (joserfc).
src/perplexity_webui_scraper/cli/commands/get_session_token.py Refactors OTP login flow and adds TOTP challenge handling during session token generation.
src/perplexity_webui_scraper/_internal/constants.py Adds the TOTP challenge verify endpoint constant.
README.md Documents that the token wizard supports TOTP 2FA.
CHANGELOG.md Notes the new TOTP 2FA support in the token generation CLI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/perplexity_webui_scraper/cli/commands/get_session_token.py
"emailLoginMethod": "web-otp",
},
)
otp_response.raise_for_status()
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@henrique-coder henrique-coder force-pushed the feature/totp-2fa-support branch from 0bfe050 to 30567f6 Compare May 23, 2026 03:15
@henrique-coder henrique-coder merged commit e37c1d7 into prod May 23, 2026
2 checks passed
@henrique-coder henrique-coder deleted the feature/totp-2fa-support branch May 23, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants