Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

402 Client Error: Payment Required for url #68

Open
adrianchapela opened this issue Sep 14, 2023 · 5 comments
Open

402 Client Error: Payment Required for url #68

adrianchapela opened this issue Sep 14, 2023 · 5 comments

Comments

@adrianchapela
Copy link

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

@darkzbaron
Copy link
Contributor

Same here!

@mkuthan
Copy link
Owner

mkuthan commented Oct 29, 2023

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

@darkzbaron
Copy link
Contributor

Sure will do when I have time and will push a PR. Thank you dev!

@adrianchapela
Copy link
Author

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:

image

@faina09
Copy link

faina09 commented Jan 4, 2024

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
main()
File "C:\nDev\GarminWorkouts\garmin-workouts\garminworkouts_main
.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=100

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

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

No branches or pull requests

4 participants