2 Commits
Author SHA1 Message Date
rick fcba32fecd Replace reCAPTCHA auth with token-bootstrap flow
The Android reCAPTCHA Enterprise key cannot be used from any
non-Android context (browser, server, headless). Certificate
pinning prevents MITM token capture. Every approach to bypass
reCAPTCHA has been exhausted.

New approach: user provides UserId + RefreshToken (one-time
extraction from the PerfectDraft app via HTTP Toolkit or similar).
The integration validates by calling /auth/renewaccesstokens,
which does NOT require reCAPTCHA, then refreshes forever.

Changes:
- config_flow.py: two-step flow (email, then tokens), validates
  via refresh endpoint, reauth asks for fresh tokens
- api.py: refresh_access_token() calls /auth/renewaccesstokens
  with {UserId, RefreshToken}, removed authenticate() method,
  added x-api-key header to all authenticated requests
- const.py: added CONF_USER_ID, removed reCAPTCHA constants
- __init__.py: passes user_id to client.set_tokens()
- strings.json + translations: updated for new flow steps
- Deleted recaptcha.py and static/recaptcha.html
- test_harness.py: updated for refresh-based flow

Made-with: Cursor
2026-04-12 12:26:12 +02:00
rick 43d6dc5bff Add local test harness and findings from API probing
test_harness.py exercises the full API flow without HA.
Credentials go in .credentials.json (gitignored).

Key findings from testing:
- reCAPTCHA is Enterprise, not standard v3
- Server-side anchor/reload tokens work but carry wrong action
- Playwright tokens carry correct action but get low trust score
- API validates both action string AND score threshold
- The exact action string is "Android_recaptchaThatWorks/login"
- Auth endpoint: POST /authentication/sign-in returns
  AccessToken, IdToken, RefreshToken on success

Made-with: Cursor
2026-04-11 20:58:27 +02:00