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

Download: 402 Client Error #109

Closed
cbueth opened this issue Feb 24, 2021 · 6 comments
Closed

Download: 402 Client Error #109

cbueth opened this issue Feb 24, 2021 · 6 comments

Comments

@cbueth
Copy link

cbueth commented Feb 24, 2021

Describe the bug
make create_dbs produces a 402 Client Error. Download errors.
The console prints:

/usr/bin/time /usr/bin/python3.7 garmin.py --all --download --import --analyze
___Downloading All Data___
Geting activities: '/HealthData/FitFiles/Activities' (1000) temp /tmp/tmpzso51vj4
0activities [00:00, ?activities/s]
Traceback (most recent call last):
  File "garmin.py", line 341, in <module>
    main(sys.argv[1:])
  File "garmin.py", line 322, in main
    download_data(args.overwrite, args.latest, args.stats)
  File "garmin.py", line 127, in download_data
    download.get_activities(activities_dir, activity_count, overwite)
  File "/GarminDB/download_garmin.py", line 283, in get_activities
    for activity in tqdm(activities, unit='activities'):
  File "/.local/lib/python3.7/site-packages/tqdm/std.py", line 1170, in __iter__
    for obj in iterable:
TypeError: 'NoneType' object is not iterable
Command exited with non-zero status 1

To Reproduce
I just installed from source on Linux (5.4.0-65-generic #73~18.04.1-Ubuntu SMP Tue Jan 19 09:02:24 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux). But with git clone --recursive https://github.com/tcgoetz/GarminDB.git instead of SSH and ran make setup (without update), then make create_dbs.

Expected behavior
I was expecting a full download and not an erroring response.

Logs
The log clearly shows the <Response [402]>.
garmin.log
Python 3.6.9, GarminDB version garmin.py 2.0.1

Additional context
The error code might sign the response is too large, but I'm unsure about that. Even with 100 and 10 as limit the same error occurs.

@matthiaswh
Copy link

matthiaswh commented Feb 24, 2021

I started seeing this yesterday as well.

Tracking down that request in connect.garmin.com, it looks like there is a header nk: NT being sent with it. No idea what it indicates, but when I remove that header it replicates the 402 response.

Edit: I confirmed that adding the nk: NT header to the __get_activity_summaries GET request fixes the 402 response. I would make a PR except I have no idea what this header means or why it would have been added or why they would return a 402 (payment required?) response. Hopefully someone with more experience with these APIs has better insight.

@skrasnow
Copy link

Very similar issue. Trying to update the Garmin database using version 1.8.1 from binaries. Terminal output is:
_DB_1.8.1/GarminDb_Darwin_1.8.1/download_update_dbs.sh
Updating existing DBs by downloading from Garmin Connect
Downloading Latest Data
Geting activities: '/Users/stanleykrasnow/HealthData/FitFiles/Activities' (10) temp /var/folders/52/658fj6dn45z3pd_djghmxw6r0000gn/T/tmpjgbxnlwh
0activities [00:00, ?activities/s]
Traceback (most recent call last):
File "garmin.py", line 340, in
File "garmin.py", line 321, in main
File "garmin.py", line 122, in download_data
File "download_garmin.py", line 283, in get_activities
File "tqdm/std.py", line 1171, in iter
TypeError: 'NoneType' object is not iterable
[64680] Failed to execute script garmin

@31SFX4
Copy link

31SFX4 commented Feb 26, 2021

Same issue here, and I can confirm that it works again for me when I add the header "nk: NT" in rest_client.py as described in the fix above.

@tcgoetz
Copy link
Owner

tcgoetz commented Feb 27, 2021

I implemented it differently here 62d9a50. Utilities is generic code and shouldn't have anything Garmin specific in it.

@tcgoetz
Copy link
Owner

tcgoetz commented Feb 27, 2021

Let me know if the fix works for you and I will merge it to master and make a release after I get some positive feedback.

@31SFX4
Copy link

31SFX4 commented Feb 27, 2021

@tcgoetz Yes, that works for me (i.e. your commit to the development branch).

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 a pull request may close this issue.

5 participants