Skip to content

fix: load the mobile sign-in page before posting credentials - #479

Merged
cyberjunky merged 1 commit into
masterfrom
fix/mobile-login-signin-page
Oct 23, 2026
Merged

cyberjunky merged 1 commit into
masterfrom
fix/mobile-login-signin-page

Conversation

@cyberjunky

Copy link
Copy Markdown
Owner

Builds on #478, which keeps the tests offline.

The mobile login strategies have answered 429 on every attempt, and it isn't a rate limit. Since the April rewrite (5-strategy chain), _do_mobile_login posts the credentials straight to /mobile/api/login without first loading the sign-in page. The original implementation, and the iOS app's web view, load /mobile/sso/en_US/sign-in first.

Tested live in the same minute, with the same fingerprint (safari_ios) and a made-up account:

Request Result
current code: direct POST 429
load the sign-in page 200, sets SESSION, __cf_bm, __cflb, …
then POST with those cookies and the page as Referer 401 INVALID_USERNAME_PASSWORD, i.e. the request was processed

Change

  • _do_mobile_login loads the sign-in page first, waits 2–5 s (MOBILE_DELAY_MIN_S/MAX_S), then posts with Referer and Accept-Language.
  • A block on the page load (427/429, or a 403 challenge) stops before any credentials are sent.

Tests

  • New tests/test_mobile_login.py: the page load happens before the POST, the POST carries the Referer and Accept-Language, and a blocked or challenged page load sends nothing. All 4 fail without the change.
  • The existing mobile test's fake session gained a get().
  • The full suite passes (637) with zero network connections. Ruff and mypy are clean.

Since the April rewrite the mobile flow posted the credentials straight
to /mobile/api/login. Garmin answers such a POST with 429 even when the
IP is not rate limited: tested with a made-up account, the direct POST
got 429, while loading /mobile/sso/en_US/sign-in first (which sets
SESSION, __cf_bm and __cflb) and posting with its Referer got
INVALID_USERNAME_PASSWORD, i.e. a processed request.

The mobile flow loads the sign-in page again, as the iOS app's web view
does, waits 2-5 s, and posts with Referer and Accept-Language. A block
on the page load (427/429, or a 403 challenge) stops before any
credentials are sent.
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 3251a6f and c635074.

📒 Files selected for processing: 5
  • CHANGELOG.md
  • garminconnect/client/constants.py
  • garminconnect/client/sso.py
  • tests/test_garmin_unit.py
  • tests/test_mobile_login.py
+------------------------------------------+
| My GPUs are ready. Let's find some bugs. |
+------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Base automatically changed from test/block-network to master October 23, 2026 11:23
@cyberjunky
cyberjunky merged commit 32c7a82 into master Oct 23, 2026
1 check was pending
@cyberjunky
cyberjunky deleted the fix/mobile-login-signin-page branch October 23, 2026 11:24
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

Successfully merging this pull request may close these issues.

1 participant