petergardfjall / garminexport

Garmin Connect activity exporter and backup tool
Apache License 2.0
507 stars 83 forks source link

Fix the 404 errors from December 2022 #92

Closed nowster closed 1 year ago

felipeam86 commented 1 year ago

Hi @nowster this is solving the issue on my end, thanks!

Would you care to share how you came up with this fix? How did you identified that you needed to add the headers {"NK": "NT"} ?

Thanks

nowster commented 1 year ago

@felipeam86

Would you care to share how you came up with this fix? How did you identified that you needed to add the headers {"NK": "NT"} ?

The clue was on #90 with the mention of https://github.com/cyberjunky/python-garminconnect

In particular: https://github.com/cyberjunky/python-garminconnect/blob/master/garminconnect/__init__.py#L216 and following.

I also noticed that it's already being done here in this code: https://github.com/petergardfjall/garminexport/blob/master/garminexport/garminclient.py#L477

62north commented 1 year ago

Had issues with this as well, this solved them, thanks.

JBuitelaar commented 1 year ago

Thanks, this also solves the problem for me.

Btw, an easier solution is just to add this header to the session (after line 126):

    self.session = session_factory()           # existing line 126
    self.session.headers.update({"nk": "NT"})  # just add this
JakobLichterfeld commented 1 year ago

This solves it for me as well!

nowster commented 1 year ago

Thanks, this also solves the problem for me.

Btw, an easier solution is just to add this header to the session (after line 126):

    self.session = session_factory()           # existing line 126
    self.session.headers.update({"nk": "NT"})  # just add this

This works for me too!

leafstrong commented 1 year ago

Thanks for the fix. Can someone make the merge and build the code so that it can be installed via pip?

chipbite commented 1 year ago

I can also confirm that adding the header nk with value NT avoids the 402 response and successfully retrieves the data. This yields a 402 error response code: curl "https://connect.garmin.com/proxy/activitylist-service/activities/chipbite?start=1&limit=10" -i

Whereas this works: curl "https://connect.garmin.com/proxy/activitylist-service/activities/chipbite?start=1&limit=10" -H "nk: NT" -i

petergardfjall commented 1 year ago

Sorry for the delay. Have been busy with other stuff for quite some time. I just merged commit 188e97e26ca2bac86d13fbe11d929a1cabf987f5 which is a condensed version of this PR. Credit to @nowster in the commit. Thanks for your contribution! Closing this PR.