petergardfjall / garminexport

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

Failing to obtain activities list #71

Closed lee-staples closed 3 years ago

lee-staples commented 3 years ago

Fails to obtain the list of activities from Garmin Connect.

Log level output of DEBUG

2021-02-24 09:19:29,300 [INFO] {list_activities}: attempt 1 ...
2021-02-24 09:19:29,300 [DEBUG] fetching activities 0 through 99 ...
2021-02-24 09:19:29,372 [DEBUG] https://connect.garmin.com:443 "GET /modern/proxy/activitylist-service/activities/search/activities?start=0&limit=100 HTTP/1.1" 402 0
2021-02-24 09:19:29,372 [DEBUG] {list_activities}: failed: error: failed to fetch activities 0 to 99 types: 402

2021-02-24 09:19:29,372 [INFO] {list_activities}: waiting 1 seconds for next attempt
2021-02-24 09:19:30,373 [INFO] {list_activities}: attempt 2 ...
2021-02-24 09:19:30,373 [DEBUG] fetching activities 0 through 99 ...
2021-02-24 09:19:30,400 [DEBUG] https://connect.garmin.com:443 "GET /modern/proxy/activitylist-service/activities/search/activities?start=0&limit=100 HTTP/1.1" 402 0
2021-02-24 09:19:30,400 [DEBUG] {list_activities}: failed: error: failed to fetch activities 0 to 99 types: 402
kfollesdal commented 3 years ago

@lee-staples have the program worked for you before? Can you login to Garmin Connect with the credentials you are using?

hab commented 3 years ago

The same happens in my setup which have been working for months

lee-staples commented 3 years ago

@lee-staples have the program worked for you before? Can you login to Garmin Connect with the credentials you are using?

Have been using weekly for months with the same command line.

garmin-backup --backup .garmin-connect-export/fit -f fit

No problems with garmin connect webpage or garmin connect app on phone.

Also tried garpy exactly the same issue with https://github.com/felipeam86/garpy

fredyr commented 3 years ago

I have also gotten the same problems as described. It seems to be some kind of update that Garmin has done. I found this forum thread describing similar problems for other 3rd party integration (garmin-uploader):

https://forums.garmin.com/apps-software/mobile-apps-web/f/garmin-connect-web/255422/connect-api-authentication-problems

petergardfjall commented 3 years ago

Thanks for supplying details. I'll try to have a look at it tonight.

kfollesdal commented 3 years ago

Have tested and can confirm that by removing modern in the url in function _fetch_activity_ids_and_ts listing activities again work. Seems like other url also have to have this change. Wil will test more and make a PR tomorrow.

I found the solutions by googling "garmin 402" since we get a 402 error. And found the tips https://github.com/cyberjunky/python-garminconnect/issues/40#issuecomment-785012949

enydog commented 3 years ago

Fails to obtain the list of activities from Garmin Connect.

Log level output of DEBUG

2021-02-24 09:19:29,300 [INFO] {list_activities}: attempt 1 ...
2021-02-24 09:19:29,300 [DEBUG] fetching activities 0 through 99 ...
2021-02-24 09:19:29,372 [DEBUG] https://connect.garmin.com:443 "GET /modern/proxy/activitylist-service/activities/search/activities?start=0&limit=100 HTTP/1.1" 402 0
2021-02-24 09:19:29,372 [DEBUG] {list_activities}: failed: error: failed to fetch activities 0 to 99 types: 402

2021-02-24 09:19:29,372 [INFO] {list_activities}: waiting 1 seconds for next attempt
2021-02-24 09:19:30,373 [INFO] {list_activities}: attempt 2 ...
2021-02-24 09:19:30,373 [DEBUG] fetching activities 0 through 99 ...
2021-02-24 09:19:30,400 [DEBUG] https://connect.garmin.com:443 "GET /modern/proxy/activitylist-service/activities/search/activities?start=0&limit=100 HTTP/1.1" 402 0
2021-02-24 09:19:30,400 [DEBUG] {list_activities}: failed: error: failed to fetch activities 0 to 99 types: 402

BASE_URL = 'https://connect.garmin.com' SSO_URL = 'https://sso.garmin.com/sso' MODERN_URL = 'https://connect.garmin.com'

MODERN_URL = 'https://connect.garmin.com/modern'

SIGNIN_URL = 'https://sso.garmin.com/sso/signin'

Taxuspt commented 3 years ago

I'm facing the same problem. Is someone working on a PR?

petergardfjall commented 3 years ago

I'm facing the same problem. Is someone working on a PR?

I am. Think I'm fairly close. I would expect a fix today.

petergardfjall commented 3 years ago

I think this should take care of it https://github.com/petergardfjall/garminexport/pull/72 Would be nice if anyone else could also verify the fix (branch fix-402-response) before I merge to master and release to PyPi.

lee-staples commented 3 years ago

I think this should take care of it #72 Would be nice if anyone else could also verify the fix (branch fix-402-response) before I merge to master and release to PyPi.

Thanks @petergardfjall .

Installed and works for my use

git clone git@github.com:petergardfjall/garminexport.git garminexport-test
cd garminexport-test
git checkout fix-402-response
pip install --user ./

garmin-backup --password <password> --backup .garmin-connect-export/fit -f fit <username>

2021-02-25 08:16:04,557 [INFO] backing up formats: fit 2021-02-25 08:16:04,557 [INFO] authenticating user ... 2021-02-25 08:16:04,557 [INFO] fetching CSRF token ... 2021-02-25 08:16:05,476 [INFO] claiming auth ticket ... 2021-02-25 08:16:07,937 [INFO] scanning activities for ... 2021-02-25 08:16:07,937 [INFO] {list_activities}: attempt 1 ... 2021-02-25 08:16:16,040 [INFO] account has a total of 1897 activities 2021-02-25 08:16:16,164 [INFO] .garmin-connect-export/fit contains 1886 backed up activities 2021-02-25 08:16:16,164 [INFO] activities that aren't backed up: 11 2021-02-25 08:16:16,164 [INFO] backing up activity 6316365313 from 2021-02-22 19:28:07+00:00 (1 out of 11) ... 2021-02-25 08:16:16,164 [INFO] {get_activity_fit}: attempt 1 ... 2021-02-25 08:16:16,495 [INFO] backing up activity 6303645342 from 2021-02-20 16:00:38+00:00 (2 out of 11) ... 2021-02-25 08:16:16,495 [INFO] {get_activity_fit}: attempt 1 ... 2021-02-25 08:16:16,790 [INFO] backing up activity 6312984487 from 2021-02-22 08:10:29+00:00 (3 out of 11) ... 2021-02-25 08:16:16,791 [INFO] {get_activity_fit}: attempt 1 ... 2021-02-25 08:16:17,023 [INFO] backing up activity 6321966401 from 2021-02-23 18:35:39+00:00 (4 out of 11) ... 2021-02-25 08:16:17,023 [INFO] {get_activity_fit}: attempt 1 ... 2021-02-25 08:16:17,404 [INFO] backing up activity 6315307082 from 2021-02-22 16:57:06+00:00 (5 out of 11) ... 2021-02-25 08:16:17,404 [INFO] {get_activity_fit}: attempt 1 ... 2021-02-25 08:16:17,649 [INFO] backing up activity 6310347876 from 2021-02-21 15:30:35+00:00 (6 out of 11) ... 2021-02-25 08:16:17,650 [INFO] {get_activity_fit}: attempt 1 ... 2021-02-25 08:16:17,988 [INFO] backing up activity 6322126250 from 2021-02-23 19:11:32+00:00 (7 out of 11) ... 2021-02-25 08:16:17,988 [INFO] {get_activity_fit}: attempt 1 ... 2021-02-25 08:16:18,333 [INFO] backing up activity 6316160776 from 2021-02-22 17:17:08+00:00 (8 out of 11) ... 2021-02-25 08:16:18,333 [INFO] {get_activity_fit}: attempt 1 ... 2021-02-25 08:16:18,688 [INFO] backing up activity 6318432054 from 2021-02-23 08:09:53+00:00 (9 out of 11) ... 2021-02-25 08:16:18,688 [INFO] {get_activity_fit}: attempt 1 ... 2021-02-25 08:16:19,032 [INFO] backing up activity 6300780985 from 2021-02-20 09:30:32+00:00 (10 out of 11) ... 2021-02-25 08:16:19,033 [INFO] {get_activity_fit}: attempt 1 ... 2021-02-25 08:16:19,284 [INFO] backing up activity 6324363848 from 2021-02-24 08:09:43+00:00 (11 out of 11) ...

petergardfjall commented 3 years ago

Thanks for trying it out @lee-staples. I'll give @kfollesdal a chance to try it out as well and if everything looks green I think it's good to go!

kfollesdal commented 3 years ago

@petergardfjall have now tested and #72 solves the problem :-)

petergardfjall commented 3 years ago

A new release 0.3.0 is available on PyPi.