garmin-workouts
garmin-workouts copied to clipboard
402 Client Error: Payment Required for url
Trying to export all workouts from garmin connect I get the next error:
requests.exceptions.HTTPError: 402 Client Error: Payment Required for url: https://connect.garmin.com/proxy/workout-service/workout/FIT/xxxxxxxx
Authentication worked fine and list also works fine
Same here!
Garmin introduced multi factor authentication and existing user/password exchange is not enough: https://support.garmin.com/en-US/?faq=uGHS8ZqOIhA0usBzBMdJu7
There is a python libarary https://github.com/matin/garth which supports MFA. Another python wrapper for GC has been already migrated to garth: https://github.com/cyberjunky/python-garminconnect/issues/141
Feel free to make a contribution to this garmin-workouts, you're welcome. It's a great opportunity to improve your Python skills, don't forget about unit tests :)
I would add another command just for storing authenticated session because it must be interactive. When session is saved, garmin-workout will work as for now.
python -m garminworkouts list
You're not logged in, call: python -m garminlogin
python -m garminlogin
Username: <input>
Password: <input>
One-time code: <input>
Success, now you can use garminworkout.
python -m garminworkouts list
188952654 VO2MAX 5x4 FTP 214, TSS 80, NP 205, IF 0.96
188952362 TEMPO 3x15 FTP 214, TSS 68, NP 172, IF 0.81
188952359 SS 3x12 FTP 214, TSS 65, NP 178, IF 0.83
Sure will do when I have time and will push a PR. Thank you dev!
Garmin introduced multi factor authentication and existing user/password exchange is not enough: https://support.garmin.com/en-US/?faq=uGHS8ZqOIhA0usBzBMdJu7
There is a python libarary https://github.com/matin/garth which supports MFA. Another python wrapper for GC has been already migrated to garth: cyberjunky/python-garminconnect#141
Feel free to make a contribution to this garmin-workouts, you're welcome. It's a great opportunity to improve your Python skills, don't forget about unit tests :)
I would add another command just for storing authenticated session because it must be interactive. When session is saved, garmin-workout will work as for now.
python -m garminworkouts list You're not logged in, call: python -m garminlogin
python -m garminlogin Username: <input> Password: <input> One-time code: <input> Success, now you can use garminworkout.
python -m garminworkouts list 188952654 VO2MAX 5x4 FTP 214, TSS 80, NP 205, IF 0.96 188952362 TEMPO 3x15 FTP 214, TSS 68, NP 172, IF 0.81 188952359 SS 3x12 FTP 214, TSS 65, NP 178, IF 0.83
MFA is the root cause of the problem? See my MFA configuration:
I have the same error; I try
python -m garminworkouts list
and got the response:
Traceback (most recent call last): File "
", line 198, in run_module_as_main File " ", line 88, in run_code File "C:\nDev\GarminWorkouts\garmin-workouts\garminworkouts_main.py", line 143, in .py", line 137, in main args.func(args) File "C:\nDev\GarminWorkouts\garmin-workouts\garminworkouts_main_.py", line 52, in command_list for workout in connection.list_workouts(): File "C:\nDev\GarminWorkouts\garmin-workouts\garminworkouts\garmin\garminclient.py", line 38, in list_workouts response.raise_for_status() File "C:\Users\stefa\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 402 Client Error: Payment Required for url: https://connect.garmin.com/proxy/workout-service/workouts?start=0&limit=100main() File "C:\nDev\GarminWorkouts\garmin-workouts\garminworkouts_main
There is no 'garminlogin' module defined (as I expected from mkuthan commented on Oct 29, 2023)
python -m garminlogin C:...\Python\Python312\python.exe: No module named garminlogin