garmin-uploader icon indicating copy to clipboard operation
garmin-uploader copied to clipboard

Authentication Failures again

Open philosowaffle opened this issue 3 years ago • 83 comments

Howdy,

Seems Garmin has yet again tweaked some things and I have several users (including myself) running into auth failures. https://github.com/philosowaffle/peloton-to-garmin/issues/109

assert self.user.authenticate(), "Failed to authenticate garmin user."
AssertionError: Failed to authenticate garmin user.

Thank you in advance for any help!

philosowaffle avatar May 18 '21 13:05 philosowaffle

Hey @philosowaffle ,

I reproduce the issue: the project unit tests are failing on the authentication.

I'll try to quickly find a fix, I'll keep you posted here

La0 avatar May 18 '21 14:05 La0

This time it's Cloudflare rejecting the requests.

I get a nice error page, with the infamous 1020 Cloudflare error. This may take some time to fix...

Screenshot 2021-05-18 at 17-53-28 Garmin Maintenance

La0 avatar May 18 '21 15:05 La0

Oh no :(

Cloudflare is awesome for keeping our favorite sites online, but as an indy dev who just wants to automate things, I hate it lol

philosowaffle avatar May 18 '21 15:05 philosowaffle

You can try this rough patch : https://github.com/La0/garmin-uploader/pull/29/files

I got some auth requests to work with this code, but now i'm getting HTTP 429 Too many requests :sob:

La0 avatar May 18 '21 16:05 La0

Thank you for the quick patch attempt! I'm at work so won't be able to verify till tonight.

On the 429 error, I've had good luck with switching onto a VPN. The 429 seems tied to IP address, so if you hop on a vpn then you get another 10-20 requests before it throws 429 again. And I think the cool off period is about 1hr.

philosowaffle avatar May 18 '21 16:05 philosowaffle

How can we pull this fix. I would like to test it.

kenlpeters avatar May 18 '21 17:05 kenlpeters

I had similar problem with my code. Actually itis the cloudflare protection that kicks in. I got it working using cloudscraper library to make the request. Here is a similar py libarary where this is duscussed.

https://github.com/cyberjunky/python-garminconnect/issues/46

Abasz avatar May 18 '21 17:05 Abasz

i can confirm Cyberjunky fix looks like its working, I'm testing it live now

BebeMischa avatar May 18 '21 18:05 BebeMischa

@kenlpeters You can try my patch with the following pip command:

pip install https://github.com/La0/garmin-uploader/archive/fix-cloudfare-errors.zip

La0 avatar May 18 '21 20:05 La0

Still get authentication failed. Not even too many requests

kenlpeters avatar May 18 '21 20:05 kenlpeters

I checked out fix-cloudfare-errors, switched conftest.py to use my dev credentials, then ran the unit tests. Unfortunately, most are still failing with Authentication Failed. Same error if I use the default guploader creds as well.

philosowaffle avatar May 18 '21 21:05 philosowaffle

Double integration (two accounts on one HA instance) running OK for more than 3 hours now, see

https://github.com/home-assistant/core/issues/50822

BebeMischa avatar May 18 '21 21:05 BebeMischa

I'll try clouscrapper tommorow

La0 avatar May 18 '21 22:05 La0

The CI is ok on the current branch, except on Python 3.7 :man_shrugging:

La0 avatar May 19 '21 08:05 La0

@La0 - let me know when 3.7 is working. Unfortunately that is the version I am running... go figure.

kenlpeters avatar May 19 '21 13:05 kenlpeters

@kenlpeters I just re-ran the CI, and it worked. I get the same results locally on multiple Python versions, and on multiple accounts / servers.

Please test this version !

La0 avatar May 19 '21 15:05 La0

I must not be downloading the proper version of the api.py. Can you link the right version.

kenlpeters avatar May 19 '21 15:05 kenlpeters

Any update on this. I am still running into the authentication error. I just think it is a fact that I am not pulling the proper version of the software.

kenlpeters avatar May 20 '21 11:05 kenlpeters

@kenlpeters I just re-ran the CI, and it worked. I get the same results locally on multiple Python versions, and on multiple accounts / servers.

Please test this version !

It's working for me now thanks!

superm1 avatar May 20 '21 11:05 superm1

Great how to get the newest version.

kenlpeters avatar May 20 '21 11:05 kenlpeters

Any update on this. I am still running into the authentication error. I just think it is a fact that I am not pulling the proper version of the software.

For me I had the old version installed in ~/.local and nothing else there. So I removed all of that directory, then cloned this repo, switched branches and ran

python3 setup.py install --user

superm1 avatar May 20 '21 11:05 superm1

Little out of my league.  Is there a link to the newest branch/repo to download On May 20, 2021, 7:57 AM -0400, Mario Limonciello @.***>, wrote:

Any update on this. I am still running into the authentication error. I just think it is a fact that I am not pulling the proper version of the software. For me I had the old version installed in ~/.local and nothing else there. So I removed all of that directory, then cloned this repo, switched branches and ran python3 setup.py install --user — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

kenlpeters avatar May 20 '21 11:05 kenlpeters

I think I downloaded the proper branch (cloud fare fixes) and unzipped and run the setup.py. Still I am getting Authenication error.

kenlpeters avatar May 20 '21 12:05 kenlpeters

I tried the CI branch as well and it did not work. So obviously I am downloading the right branch.

kenlpeters avatar May 20 '21 12:05 kenlpeters

I think I downloaded the proper branch (cloud fare fixes) and unzipped and run the setup.py. Still I am getting Authenication error.

Assuming you're not hitting a different failure and are running the wrong code still - if I was to guess, you're still getting the wrong copy from a local install somewhere else that has higher precedence (like site-packages or dist-packages). You should try doing pip uninstall garmin-uploader.

superm1 avatar May 20 '21 12:05 superm1

Did you download the cloud fare fixes branch?

kenlpeters avatar May 20 '21 13:05 kenlpeters

Yes. Basically I did:

rm ~/.local -r
git clone https://github.com/La0/garmin-uploader/
git checkout fix-cloudfare-errors
python3 setup.py install --user
gupload .....

and verified it's working for me now.

superm1 avatar May 20 '21 13:05 superm1

Another option, if you do not want to bother with installing/uninstalling packages:

> git clone https://github.com/La0/garmin-uploader/
> git checkout fix-cloudfare-errors
> pip install -r requirements.txt
> pip install -r requirements-tests.txt
> cd tests
> pytest 

This runs the unit tests with a default set of credentials. If you would like to try running the unit tests with your personal credentials then modify here.

@La0 , assuming what I have outlined above is correct, I am still seeing Authentication failures :(

It fails the check on line 134 in api.py and raises the Authentication failed. exception (which bubbles up and is masked by the Invalid Credentials exception). Fails for both your test user and my with my user creds. I am on python 3.6.4.

@superm1 pardon snooping on your GH account, but looks like you're based in Texas. I am also based in Texas, so I guess that rules out different regional rules CloudFlare could be enforcing.

philosowaffle avatar May 20 '21 13:05 philosowaffle

So I am not getting invalid credentials even though my credentials are correct.

kenlpeters avatar May 20 '21 13:05 kenlpeters

@philosowaffle - Same here. Python 3.7 invalid credentials both with default and my person ones.

kenlpeters avatar May 20 '21 13:05 kenlpeters