petergardfjall / garminexport

Garmin Connect activity exporter and backup tool
Apache License 2.0
500 stars 85 forks source link

Fails with HTTP 403 error when attempting to login with correct credentials #109

Closed miguno closed 10 months ago

miguno commented 10 months ago

First, thanks so much for maintaining this project!

I have been using garminexport since several months, and it always worked flawlessly thus far. Note that I am not downloading my Garmin activities daily, but only every couple of weeks, so I can't tell whether this problem occurred only today or whether this issue has been existing for longer.

Environment:

Today, when I tried to download with my wrapper script for garminexport, the attempt failed with an HTTP 403 error. The error says authentication attempt failed with 403, but the login credentials are 100% correct (I verified it via a manual login on Garmin.com, just in case).

2023-11-29 13:56:27,447 [INFO] backing up formats: json_summary, json_details, gpx, tcx, fit
Enter password:
2023-11-29 13:56:32,035 [INFO] authenticating user ...
2023-11-29 13:56:32,035 [INFO] passing login credentials ...
2023-11-29 13:56:32,127 [ERROR] failed with exception: authentication attempt failed with 403: <!DOCTYPE html><html lang="en-US"><head><title>Just a moment...</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=Edge"><meta name="robots" content="noindex,nofollow"><meta name="viewport" content="width=device-width,initial-scale=1"><link href="/cdn-cgi/styles/challenges.css" rel="stylesheet"><meta http-equiv="refresh" content="375"></head><body class="no-js"><div class="main-wrapper" role="main"><div class="main-content"><noscript><div id="challenge-error-title"><div class="h2"><span class="icon-wrapper"><div class="heading-icon warning-icon"></div></span><span id="challenge-error-text">Enable JavaScript and cookies to continue</span></div></div></noscript></div></div><script>(function(){window._cf_chl_opt={cvId: '2',cZone: "sso.garmin.com",cType: 'managed',cNounce: '16959',cRay: '82db02e0c9022c25',cHash: 'd30b2ab2e2d61dc',cUPMDTk: "\/portal\/api\/login?clientId=GarminConnect&service=https%3A%2F%2Fconnect.garmin.com%2Fmodern%2F&gauthHost=https%3A%2F%2Fsso.garmin.com%2Fsso& [...rest removed...]

Have you seen this before?

zxxxh commented 10 months ago

Install with the _impersonatebrowser extra.

pip install "garminexport[impersonate_browser]" or pip install garminexport --upgrade "garminexport[impersonate_browser]"

miguno commented 10 months ago

That fixes it, thanks a lot!