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

AssertionError: Failed to authenticate garmin user. #109

Closed
johnmaconline opened this issue May 17, 2021 · 58 comments
Closed

AssertionError: Failed to authenticate garmin user. #109

johnmaconline opened this issue May 17, 2021 · 58 comments
Labels

Comments

@johnmaconline
Copy link

johnmaconline commented May 17, 2021

Just started getting this once I pulled the latest:

INFO:peloton-to-garmin:Uploading activities to Garmin...
2021-05-17 10:58:30,399 [CRITICAL] Login Failure: Authentification failed.
CRITICAL:garmin_uploader:Login Failure: Authentification failed.
INFO:peloton-to-garmin:Failed to upload to Garmin. With error: Failed to authenticate garmin user.
Press the key to quit...
Traceback (most recent call last):
File "/Users/johnmacdonald/code/other/peloton-to-garmin/peloton-to-garmin.py", line 246, in
PelotonToGarmin.run(config)
File "/Users/johnmacdonald/code/other/peloton-to-garmin/peloton-to-garmin.py", line 224, in run
raise e
File "/Users/johnmacdonald/code/other/peloton-to-garmin/peloton-to-garmin.py", line 219, in run
garminUploader.uploadToGarmin(garminUploadHistoryTable)
File "/Users/johnmacdonald/code/other/peloton-to-garmin/lib/garminClient.py", line 29, in uploadToGarmin
assert self.user.authenticate(), "Failed to authenticate garmin user."
AssertionError: Failed to authenticate garmin user.

@philosowaffle
Copy link
Owner

philosowaffle commented May 17, 2021

Another trace from @grizzls

2021-05-17 12:57:07,243 [CRITICAL] Login Failure: Authentification failed.
[12:57:07 ERR] Failed to upload workouts. GUpload had exit code of 1
[12:57:07 ERR] Uncaught Exception.
Garmin.GarminUploadException: GUpload Exit Code: 1 - GUpload returned an error code. Failed to upload workouts.
   at Garmin.GarminUploader.UploadViaPython(String[] files) in /build/src/Garmin/GarminUploader.cs:line 111
   at Garmin.GarminUploader.UploadToGarmin() in /build/src/Garmin/GarminUploader.cs:line 50
   at PelotonToGarminConsole.Program.RunAsync(Configuration config) in /build/src/PelotonToGarminConsole/Program.cs:line 133
   at PelotonToGarminConsole.Program.Main(String[] args) in /build/src/PelotonToGarminConsole/Program.cs:line 93
Unhandled exception. Garmin.GarminUploadException: GUpload Exit Code: 1 - GUpload returned an error code. Failed to upload workouts.
   at Garmin.GarminUploader.UploadViaPython(String[] files) in /build/src/Garmin/GarminUploader.cs:line 111
   at Garmin.GarminUploader.UploadToGarmin() in /build/src/Garmin/GarminUploader.cs:line 50
   at PelotonToGarminConsole.Program.RunAsync(Configuration config) in /build/src/PelotonToGarminConsole/Program.cs:line 133
   at PelotonToGarminConsole.Program.Main(String[] args) in /build/src/PelotonToGarminConsole/Program.cs:line 93

@philosowaffle philosowaffle pinned this issue May 17, 2021
@philosowaffle philosowaffle added blocked and removed v2 labels May 17, 2021
@philosowaffle
Copy link
Owner

I am able to reproduce locally and I have confirmed the authentication error is appearing on both V1 and V2, which leads me to conclude this is not related to any code change, but rather Garmin has changed some of their authentication rules.

This will likely need to be resolved in the garmin-uploader project.

V1 stack trace:

INFO:peloton-to-garmin:Get workout: bc143ae7289b45e78eec42617b3a2b1c,
INFO:peloton-to-garmin:Downloading bc143ae7289b45e78eec42617b3a2b1c : 45 min Power Zone Endurance Ride with Olivia Amato (cycling) at Sun May 16 15:49:50 2021,
INFO:peloton-to-garmin:Get workout samples,
INFO:peloton-to-garmin:Get workout summary,
INFO:peloton-to-garmin:Get workout: 2da4e46a2d7546b3a29039023a85b01d,
INFO:peloton-to-garmin:Downloading 2da4e46a2d7546b3a29039023a85b01d : 45 min Power Zone Endurance Ride with Matt Wilpers (cycling) at Wed May 12 16:15:36 2021,
INFO:peloton-to-garmin:Get workout samples,
INFO:peloton-to-garmin:Get workout summary,
INFO:peloton-to-garmin:Get workout: 4b4259f950ab40a4b058d4e53e01ebf8,
INFO:peloton-to-garmin:Downloading 4b4259f950ab40a4b058d4e53e01ebf8 : 30 min Power Zone Endurance Rock Ride with Matt Wilpers (cycling) at Wed May  5 19:15:48 2021,
INFO:peloton-to-garmin:Get workout samples,
INFO:peloton-to-garmin:Get workout summary,
INFO:peloton-to-garmin:Begin processing 4 workout files.,
INFO:peloton-to-garmin:Processing 4b4259f950ab40a4b058d4e53e01ebf8 : 30 min Power Zone Endurance Rock Ride with Matt Wilpers (cycling) at Wed May  5 19:15:48 2021,
INFO:peloton-to-garmin:Wrote TCX file: 1620242148-30 min Power Zone Endurance Rock Ride with Matt Wilpers-4b4259f950ab40a4b058d4e53e01ebf8.tcx,
INFO:peloton-to-garmin:Queuing activity for upload: 30 min Power Zone Endurance Rock Ride with Matt Wilpers,
INFO:peloton-to-garmin:Processing bc143ae7289b45e78eec42617b3a2b1c : 45 min Power Zone Endurance Ride with Olivia Amato (cycling) at Sun May 16 15:49:50 2021,
INFO:peloton-to-garmin:Wrote TCX file: 1621180190-45 min Power Zone Endurance Ride with Olivia Amato-bc143ae7289b45e78eec42617b3a2b1c.tcx,
INFO:peloton-to-garmin:Queuing activity for upload: 45 min Power Zone Endurance Ride with Olivia Amato,
INFO:peloton-to-garmin:Processing 2da4e46a2d7546b3a29039023a85b01d : 45 min Power Zone Endurance Ride with Matt Wilpers (cycling) at Wed May 12 16:15:36 2021,
INFO:peloton-to-garmin:Wrote TCX file: 1620836136-45 min Power Zone Endurance Ride with Matt Wilpers-2da4e46a2d7546b3a29039023a85b01d.tcx,
INFO:peloton-to-garmin:Queuing activity for upload: 45 min Power Zone Endurance Ride with Matt Wilpers,
INFO:peloton-to-garmin:Processing 754d75c024a24a1c86be99cce223e660 : 30 min Big Sur Ride (cycling) at Sun May 16 16:37:47 2021,
INFO:peloton-to-garmin:Wrote TCX file: 1621183067-30 min Big Sur Ride-754d75c024a24a1c86be99cce223e660.tcx,
INFO:peloton-to-garmin:Queuing activity for upload: 30 min Big Sur Ride,
INFO:peloton-to-garmin:Uploading activities to Garmin...,
2021-05-17 17:53:57,739 [CRITICAL] Login Failure: Authentification failed.,
CRITICAL:garmin_uploader:Login Failure: Authentification failed.,
INFO:peloton-to-garmin:Failed to upload to Garmin. With error: Failed to authenticate garmin user.,
Traceback (most recent call last):,
  File "/opt/app/peloton-to-garmin.py", line 219, in run,
    garminUploader.uploadToGarmin(garminUploadHistoryTable),
  File "/opt/app/lib/garminClient.py", line 29, in uploadToGarmin,
    assert self.user.authenticate(), "Failed to authenticate garmin user.",
AssertionError: Failed to authenticate garmin user.,
,
During handling of the above exception, another exception occurred:,
,
Traceback (most recent call last):,
  File "/opt/app/peloton-to-garmin.py", line 242, in <module>,
    PelotonToGarmin.run(config),
  File "/opt/app/peloton-to-garmin.py", line 223, in run,
    input("Press the <ENTER> key to quit..."),
EOFError: EOF when reading a line,
Press the <ENTER> key to quit...

@johnmaconline
Copy link
Author

@philosowaffle I concur (through specific garmin-uploader testing) that the likely culprit is Garmin changing something on their side.

@kenlpeters
Copy link

Plus 1. Same issue here.

@kenlpeters
Copy link

Plot thickens. If I try to manually import the TCX file from Peloton there is done of data not imported. The work type is wrong (walking show running, strength show other). So the import definitely seems to have changed. I wonder if a FIT file would be different. Is there a way to generate a FIT file instead of TCX?

@johnmaconline
Copy link
Author

@kenlpeters I've confirmed your findings on my side as well.

I'm trying to find if Garmin has published any changes to the API or TCX files, but I'm not yet familiar with where to look. I am a sw developer, but this is my first time diving into Garmin and it's API's, etc.

The red boxes show the same activity from 2 different days (and 2 different import days). The top one does not pick up the title correctly.

The green boxes show similar activities from different import days, and both the "type" and "title" are not imported correctly.

Screen Shot 2021-05-18 at 8 11 01 AM

@kenlpeters
Copy link

kenlpeters commented May 18, 2021 via email

@johnmaconline
Copy link
Author

@kenlpeters The v2 working branch of @philosowaffle's project here creates and uses FIT files. I've not yet tried it, but maybe you do that test.

Further testing/observation reveals a confirmation that TCX file created from the Peloton input has not changed. Therefore, this is further confirmation that the issue is on the Garmin side.

image

@kenlpeters
Copy link

kenlpeters commented May 18, 2021 via email

@philosowaffle
Copy link
Owner

philosowaffle commented May 18, 2021

@kenlpeters @johnmaconline thank you for taking time to look into this further. Let me give you a bit more info before you get stuck going to far down the wrong rabbit hole :)

  1. Version 1 only supports TCX files. Version 2 does both FIT and TCX and can be found here
  2. Whenever you manually upload a TCX file to Garmin, for some reason, Garmin has never honored the Title nor Activity Type found in the file. I don't know why, but its always been this way for P2G.

So, how has title, upload, and activity type been working so far? The answer is we use a 3rd party library garmin-uploader maintained by another great dev here on github, @La0. Some notes on this project:

  1. Garmin does not publicly expose any documentation about their API. In fact they lock it behind a paywall and are very picky about who they allow access to it.
  2. The garmin-uploader project dev has reversed engineered a couple key API endpoints using the browser and wrapped that logic into the garmin-uploader python library. P2G uses this library for all uploading capabilities.
  3. In addition to providing the upload feature, this API also allows us to set the Activity Title and Activity Type, which is why they appear correctly in Garmin Connect when uploaded automatically.
  4. The garmin-uploader project has good unit tests that can be used to help debug the issue.

So, next step is really we just need to create an issue on the garmin-uploader repo.

@kenlpeters
Copy link

kenlpeters commented May 18, 2021 via email

@philosowaffle
Copy link
Owner

philosowaffle commented May 18, 2021

Guide for getting up and running on V2: https://github.com/philosowaffle/peloton-to-garmin/wiki/Migrating-from-v1-to-v2
Link to all V2 Documentation: https://github.com/philosowaffle/peloton-to-garmin/wiki/Peloton-To-Garmin---v2

Both V1 and V2 can be installed in different directories and run independently, they do not interfere with each other. Other than they will both try to upload the same stuff to Garmin which could cause duplicates.

I'm still trying to improve the docs so feedback appreciated over in the Discussion forum.

Do FIT files import the type, etc, when uploaded manually?

Just did a quick test and appears the answer is yes.

@kenlpeters
Copy link

kenlpeters commented May 18, 2021 via email

@philosowaffle
Copy link
Owner

Docker or building from Source would work on Linux.

@philosowaffle
Copy link
Owner

Issued created on garmin-uploader: La0/garmin-uploader#28

@kenlpeters
Copy link

Working on install V2. Question - do FIT files count towards challenges?

@philosowaffle
Copy link
Owner

They should. While I don't have support yet for the custom device code that was added to V1, I do have a default device configured that seems to be working for Badges, and I would assume Challenges as well.

@kenlpeters
Copy link

kenlpeters commented May 18, 2021

So when I try ot run in Lunix I get this : "Call Failed with status 401 (Unauthorized) https://api.onepeloton.com/auth/login. I double checked my configuration.local.json and my username and password is correct.

I fixed this by making sure the config file was in the proper folder :)

@superm1
Copy link

superm1 commented May 18, 2021

Digging discovered that display_name "Pace", values:[ null, null, null, 60.0, 46.15....] These null's seem to be the issue. May need to trap for null and default to 0.0.

This sounds like a separate issue from the authentication issue we're all seeing though. You can at least get in, and then you're hitting some processing problems. Maybe split that to another issue?

@kenlpeters
Copy link

Good idea - I deleted them from this thread and opened a new issue.

@philosowaffle
Copy link
Owner

Update:

The dev from garmin-uploader has identified the issue, but unfortunately Garmin has really stepped up their auth game. Finding if there is a fix or workaround will take some time.

For the time being, you will need to adjust your workflows to manually upload to Garmin.

@philosowaffle
Copy link
Owner

I will not make a new release until we are sure of the fix. In the meantime, how you test the fix depends on how you are running the code.

If you're running docker, pull the latest tag instead of the release tag.

If you're running from source, i.e. you downloaded the code to your machine and run python peloton-to-garmin.py to sync, then open the command line and run the below commands:

> pip uninstall garmin-uploader
> pip install https://github.com/La0/garmin-uploader/archive/cloudscraper.zip

If you are using the windows exe, you'll have to wait a bit longer till we have verified the fix and I make a new release.

@jmnieves
Copy link

@philosowaffle ok I am using the the Windows exe so I'll sit back and wait for the final update. Thanks!

@mediacrave
Copy link

I'm using source method on Ubuntu and I keep getting failed to auth using cloudscraper.zip.

2021-05-29 15:01:05,440 [CRITICAL] Login Failure: Authentification failed.
CRITICAL:garmin_uploader:Login Failure: Authentification failed.
INFO:peloton-to-garmin:Failed to upload to Garmin. With error: Failed to authenticate garmin user.
Press the key to quit...
Traceback (most recent call last):
File "peloton-to-garmin.py", line 246, in
PelotonToGarmin.run(config)
File "peloton-to-garmin.py", line 224, in run
raise e
File "peloton-to-garmin.py", line 219, in run
garminUploader.uploadToGarmin(garminUploadHistoryTable)
File "/home/musicking/Downloads/peloton-to-garmin-master/lib/garminClient.py", line 29, in uploadToGarmin
assert self.user.authenticate(), "Failed to authenticate garmin user."
AssertionError: Failed to authenticate garmin user.

@jrussell11
Copy link

I get an auth success when uploading exactly 1 activity, an auth failure when uploading > 1 activities. This is with version 1.2, running from source on Windows.

C:\Users\fatca\Downloads\p2g12-src>python peloton-to-garmin.py
How many past activities do you want to grab?  1
INFO:peloton-to-garmin:Begin processing 1 workout files.
INFO:peloton-to-garmin:Processing e2e52c00ca794be681fb3e11446bd0d8 : 45 min Power Zone Endurance Ride with Matt Wilpers (cycling) at Mon May 31 21:59:13 2021
INFO:peloton-to-garmin:Wrote TCX file: 1622523553-45 min Power Zone Endurance Ride with Matt Wilpers-e2e52c00ca794be681fb3e11446bd0d8.tcx
INFO:peloton-to-garmin:Queuing activity for upload: 45 min Power Zone Endurance Ride with Matt Wilpers
INFO:peloton-to-garmin:Uploading activities to Garmin...
INFO:peloton-to-garmin.garminClient:Uploaded activity: 45 min Power Zone Endurance Ride with Matt Wilpers
INFO:peloton-to-garmin:Done!
INFO:peloton-to-garmin:Your Garmin TCX files can be found in the Output directory: Output

C:\Users\fatca\Downloads\p2g12-src>python peloton-to-garmin.py
How many past activities do you want to grab?  5
INFO:peloton-to-garmin:Get workout: 95190bba806642ea822eb27d17e3a63d
INFO:peloton-to-garmin:Downloading 95190bba806642ea822eb27d17e3a63d : 30 min Hawaii Ride (cycling) at Thu May 27 21:13:15 2021
INFO:peloton-to-garmin:Get workout samples
INFO:peloton-to-garmin:Get workout summary
INFO:peloton-to-garmin:Get workout: 1e359b31c1e244f0ab27d77c5b1e7820
INFO:peloton-to-garmin:Downloading 1e359b31c1e244f0ab27d77c5b1e7820 : 60 min Power Zone Ride with Matt Wilpers (cycling) at Mon May 24 21:24:51 2021
INFO:peloton-to-garmin:Get workout samples
INFO:peloton-to-garmin:Get workout summary
INFO:peloton-to-garmin:Get workout: 2671b04ae6bf4582a90e333075248420
INFO:peloton-to-garmin:Downloading 2671b04ae6bf4582a90e333075248420 : 20 min EDM Ride with Emma Lovewell (cycling) at Sun May 23 22:27:08 2021
INFO:peloton-to-garmin:Get workout samples
INFO:peloton-to-garmin:Get workout summary
INFO:peloton-to-garmin:Get workout: f8093de2152b4bb49222e378920d8c7c
INFO:peloton-to-garmin:Downloading f8093de2152b4bb49222e378920d8c7c : 45 min Power Zone Endurance Ride with Matt Wilpers (cycling) at Fri May 21 21:00:33 2021
INFO:peloton-to-garmin:Get workout samples
INFO:peloton-to-garmin:Get workout summary
INFO:peloton-to-garmin:Begin processing 5 workout files.
INFO:peloton-to-garmin:Processing f8093de2152b4bb49222e378920d8c7c : 45 min Power Zone Endurance Ride with Matt Wilpers (cycling) at Fri May 21 21:00:33 2021
INFO:peloton-to-garmin:Wrote TCX file: 1621656033-45 min Power Zone Endurance Ride with Matt Wilpers-f8093de2152b4bb49222e378920d8c7c.tcx
INFO:peloton-to-garmin:Queuing activity for upload: 45 min Power Zone Endurance Ride with Matt Wilpers
INFO:peloton-to-garmin:Processing 2671b04ae6bf4582a90e333075248420 : 20 min EDM Ride with Emma Lovewell (cycling) at Sun May 23 22:27:08 2021
INFO:peloton-to-garmin:Wrote TCX file: 1621834028-20 min EDM Ride with Emma Lovewell-2671b04ae6bf4582a90e333075248420.tcx
INFO:peloton-to-garmin:Queuing activity for upload: 20 min EDM Ride with Emma Lovewell
INFO:peloton-to-garmin:Processing 1e359b31c1e244f0ab27d77c5b1e7820 : 60 min Power Zone Ride with Matt Wilpers (cycling) at Mon May 24 21:24:51 2021
INFO:peloton-to-garmin:Wrote TCX file: 1621916691-60 min Power Zone Ride with Matt Wilpers-1e359b31c1e244f0ab27d77c5b1e7820.tcx
INFO:peloton-to-garmin:Queuing activity for upload: 60 min Power Zone Ride with Matt Wilpers
INFO:peloton-to-garmin:Processing 95190bba806642ea822eb27d17e3a63d : 30 min Hawaii Ride (cycling) at Thu May 27 21:13:15 2021
INFO:peloton-to-garmin:Wrote TCX file: 1622175195-30 min Hawaii Ride-95190bba806642ea822eb27d17e3a63d.tcx
INFO:peloton-to-garmin:Queuing activity for upload: 30 min Hawaii Ride
INFO:peloton-to-garmin:Processing e2e52c00ca794be681fb3e11446bd0d8 : 45 min Power Zone Endurance Ride with Matt Wilpers (cycling) at Mon May 31 21:59:13 2021
INFO:peloton-to-garmin:Wrote TCX file: 1622523553-45 min Power Zone Endurance Ride with Matt Wilpers-e2e52c00ca794be681fb3e11446bd0d8.tcx
INFO:peloton-to-garmin:Workout already uploaded to garmin, skipping...
INFO:peloton-to-garmin:Uploading activities to Garmin...
2021-06-01 12:30:11,437 [CRITICAL] Login Failure: Authentification failed.
CRITICAL:garmin_uploader:Login Failure: Authentification failed.
INFO:peloton-to-garmin:Failed to upload to Garmin. With error: Failed to authenticate garmin user.

Traceback (most recent call last):
  File "peloton-to-garmin.py", line 246, in <module>
    PelotonToGarmin.run(config)
  File "peloton-to-garmin.py", line 224, in run
    raise e
  File "peloton-to-garmin.py", line 219, in run
    garminUploader.uploadToGarmin(garminUploadHistoryTable)
  File "C:\Users\fatca\Downloads\p2g12-src\lib\garminClient.py", line 29, in uploadToGarmin
    assert self.user.authenticate(), "Failed to authenticate garmin user."
AssertionError: Failed to authenticate garmin user.

I reproduced this 5 times in a row, so do not believe this is transient. Further, it can be reproduced by starting with uploading 1 activity, and then incrementing the number of activities to upload by 1 each time, so that the previously uploaded activity is skipped, resulting in 1 actual upload (which succeeds, even though it is an older activity).

@kenlpeters
Copy link

Maybe unrelated, but I am using the cloud scraper version with version 1 of P2G. I usually perform the upload using a URL call to a Node JS server which calls the python command and returns the log. This worked great, but the cloud scraper version does not work. If I run the command using SSH is works perfectly. Just strange that calling the command through the node is server fails (no log info) but works through SSH. I will play with a little more and see what I can do.

@kenlpeters
Copy link

Scratch the last comment. I have TSR of an older version running with PM2. Once I killed PM2 and restarted the server ... boom. We server back working. IOS shortcuts works. I am back in business.

@philosowaffle
Copy link
Owner

For those of you waiting on a windows exe (@jmnieves) V1 & V2 windows exe's have been updated to include the crowdscraper fix.

V1 - https://github.com/philosowaffle/peloton-to-garmin/tree/master/dist
V2 - https://github.com/philosowaffle/peloton-to-garmin/actions/runs/897894847 (look in the Artifacts section)

Please leave your reaction:
👍 working
👎 not working

@LindsFisch
Copy link

Downloaded V1 of exe this morning - updated config and ran.

How many past activities do you want to grab?  1
INFO:peloton-to-garmin:Begin processing 1 workout files.
INFO:peloton-to-garmin:Processing 72614b6d85fe4baaa6793d6d023809aa : 10 min Sleep Meditation with Aditi Shah (meditation) at Tue Jun  1 21:07:21 2021
INFO:peloton-to-garmin:Wrote TCX file: 1622599641-10 min Sleep Meditation with Aditi Shah-72614b6d85fe4baaa6793d6d023809aa.tcx
INFO:peloton-to-garmin:Queuing activity for upload: 10 min Sleep Meditation with Aditi Shah
INFO:peloton-to-garmin:Uploading activities to Garmin...
2021-06-02 05:41:15,643 [CRITICAL] Login Failure: [Errno 2] No such file or directory: 'C:\\Users\\Linds\\Desktop\\Lindsey - PelotonNEW\\cloudscraper\\user_agent\\browsers.json'
CRITICAL:garmin_uploader:Login Failure: [Errno 2] No such file or directory: 'C:\\Users\\Linds\\Desktop\\Lindsey - PelotonNEW\\cloudscraper\\user_agent\\browsers.json'
INFO:peloton-to-garmin:Failed to upload to Garmin. With error: Failed to authenticate garmin user.

May be missing something.. is 5a.

@philosowaffle
Copy link
Owner

I noticed in your log there is this nested error:

[Errno 2] No such file or directory: 'C:\\Users\\Linds\\Desktop\\Lindsey - PelotonNEW\\cloudscraper\\user_agent\\browsers.json'

And my theory is that it does not like the space in the folder name. Sometimes code has trouble handling this scenario. My hunch is the new cloudscraper library that has been pulled in, may have trouble handling spaces in the file path.

@LindsFisch just to experiment, can you rename this folder:

Lindsey - PelotonNEW

to:

Lindsey_PelotonNEW

And give it another go?

@LindsFisch
Copy link

LindsFisch commented Jun 2, 2021

@philosowaffle - renamed to Lindsey_PelotonNEW PelotonNEW pelotonnew and didn't like any of em. Same error.

How many past activities do you want to grab?  1
INFO:peloton-to-garmin:Begin processing 1 workout files.
INFO:peloton-to-garmin:Processing 2757b03f65954014a42282bcb50d48f4 : 30 min Power Yoga with Anna Greenberg (yoga) at Wed Jun  2 07:00:54 2021
INFO:peloton-to-garmin:Wrote TCX file: 1622635254-30 min Power Yoga with Anna Greenberg-2757b03f65954014a42282bcb50d48f4.tcx
INFO:peloton-to-garmin:Queuing activity for upload: 30 min Power Yoga with Anna Greenberg
INFO:peloton-to-garmin:Uploading activities to Garmin...
2021-06-02 09:17:23,806 [CRITICAL] Login Failure: [Errno 2] No such file or directory: 'C:\\Users\\Linds\\Desktop\\PelotonNEW\\cloudscraper\\user_agent\\browsers.json'
CRITICAL:garmin_uploader:Login Failure: [Errno 2] No such file or directory: 'C:\\Users\\Linds\\Desktop\\PelotonNEW\\cloudscraper\\user_agent\\browsers.json'
INFO:peloton-to-garmin:Failed to upload to Garmin. With error: Failed to authenticate garmin user.

I see there is 1 more down-vote on the windows exe announcement. Curious if we're having similar issues

@philosowaffle
Copy link
Owner

Thanks for trying that out. I tested the V2 exe, but have not tested the V1 exe yet (just assumed it would work), maybe I messed something up while creating the V1 exe. I'll test out the V1 exe after work today and see if I can reproduce the error.

@philosowaffle
Copy link
Owner

@LindsFisch I am able to reproduce the V1 windows exe issue and will need to investigate further. It seems for some reason the new cloudscraper library does not like being packaged up.

@philosowaffle
Copy link
Owner

philosowaffle commented Jun 6, 2021

For people running V2 (docker or source):

I have observed on my local install that the cloudscraper fix does not work 100% of the time, it will randomly fail to authenticate. Previously, if you had polling enabled and P2G failed to authenticate with Garmin it would kill the job immediately. I have pushed a small update that changes this behavior. Instead of killing the job, it will now log an error and sleep till the next sync interval at which point it will try to upload again. You can still choose to manually upload your workouts (no need to worry about duplicates), but now you don't have to worry about the sync job dying on you and having to restart it. It will keep running, keep converting workouts, and keep trying to upload to Garmin.

And if you happen to be one of the nerds using the Prometheus metrics, there is a new Health metric that will report as UnHealthy when the Garmin upload fails. 0=Dead, 1=UnHealthy, 2=Healthy

Regarding windows exe issue:

I have not made any progress here yet.

@superm1
Copy link

superm1 commented Jun 6, 2021

Instead of killing the job, it will now log an error and sleep till the next sync interval at which point it will try to upload again.

I think it might be worth setting the default to write out the fit file in the config file until it's higher reliability for uploads too.

@philosowaffle
Copy link
Owner

philosowaffle commented Jun 26, 2021

For anyone still experiencing authentication issues I have just added a new experimental feature you can try out #131

To test this out you will need to:

  1. Get the latest version of the code
    1. If using Source, pull the latest version of the master branch
    2. If using Docker, pull the latest image tag
    3. If using Windows Exe, download latest from here
  2. Delete the App.PythonAndGUploadInstalled line from your config file.
  3. Add a new config value Garmin.UploadStrategy and set it to 2.

This new strategy works for me on one computer using both source and the win exe, but is still not working for me in the Docker container (cloudflare is blocking with a 1020 error code in Docker container). Still investigating how/why CloudFlare is flagging the docker container but not the other methods.

If UploadStrategy 2 is working for you leave a 👍 else leave a 👎 on this comment.

@dkmcgowan
Copy link

I will test once you get atleast one successful run with docker since that's my method, strange the code and request would look different

@philosowaffle
Copy link
Owner

@dkmcgowan docker is my primary method as well. But am definitely stumped right now on what could possibly be different between the containerized api request vs. non-containerized api request.

@dkmcgowan
Copy link

dkmcgowan commented Jun 26, 2021

Docker has a different network stack and it gets NAT out the primary interface, not sure if that changes or adds anything to the request, assume you inspected raw request? See if you change network type from bridge to macvlan and then the container would be on the adapter, see if it changes at all

@dkmcgowan
Copy link

dkmcgowan commented Jun 26, 2021

Also maybe try to switch from bridge to host before going down macvlan method, then something like Wireshark can maybe tell you what's changing in the request

@philosowaffle
Copy link
Owner

So far I have tried host mode and also tried running the container behind a vpn network. Still gets flagged by cloudflare.

I've checked the headers and cookies on the request and they appear identical between a local run and a container run. Confirmed that the cloudflare cookies from the initial request are getting persisted onto the second request. Its the second request that fails with 403. But so far I have only been inspecting traffic as logged by my tracing inside the container, I suppose next step is to use something like wire shark to see if the request is changing at all as it leaves the container.

Something is definitely unique about these requests otherwise cloudflare would not be able to differentiate them. My public IP address is not changing, and I'm using the same UserAgent in all cases.

@philosowaffle
Copy link
Owner

philosowaffle commented Jun 27, 2021

@dkmcgowan the Docker image is now working. I had to switch from an Alpine based image to Debian and it started working. I suppose Alpine may have been missing some dependency that caused the HTTP requests to be handled slightly differently.

@dkmcgowan
Copy link

Awesome, updating now

@philosowaffle
Copy link
Owner

I think we have this fixed for the majority of people. If you haven't updated yet, you'll want to get version 2.0.3 that was just released. With this version you'll be able to configure whichever of the 3 Garmin.UploadStrategy's works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants