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

withings_sync.garmin.APIException: SSO error 401 #31

Closed
midzelis opened this issue May 29, 2021 · 12 comments
Closed

withings_sync.garmin.APIException: SSO error 401 #31

midzelis opened this issue May 29, 2021 · 12 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@midzelis
Copy link

midzelis commented May 29, 2021

2021-05-29 13:21:47,146 - withings - INFO - Refresh Access Token
2021-05-29 13:21:47,954 - withings - INFO - Get Measurements
2021-05-29 13:21:48,352 - root - INFO - No Trainerroad username or a new measurement - skipping sync
Traceback (most recent call last):
  File "/usr/local/bin/withings-sync", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/withings_sync/sync.py", line 196, in main
    sync(**vars(args))
  File "/usr/local/lib/python3.8/dist-packages/withings_sync/sync.py", line 184, in sync
    session = garmin.login(garmin_username, garmin_password)
  File "/usr/local/lib/python3.8/dist-packages/withings_sync/garmin.py", line 156, in login
    session = self._get_session(email=username, password=password)
  File "/usr/local/lib/python3.8/dist-packages/withings_sync/garmin.py", line 93, in _get_session
    raise APIException('SSO error %s %s' % (ssoResp.status_code, ssoResp.text))
withings_sync.garmin.APIException: SSO error 401 <!DOCTYPE html>
<html lang="en" class="no-js">
    <head>
        <script charset='UTF-8' type="ebbd33b1756dc6ae370d3b32-text/javascript">
            window['adrum-start-time'] = new Date().getTime();
            (function(config){
                config.appKey = 'AD-AAB-AAM-PWF';
                config.adrumExtUrlHttp = 'http://cdn.appdynamics.com';
                config.adrumExtUrlHttps = 'https://cdn.appdynamics.com';
                config.beaconUrlHttp = 'http://col.eum-appdynamics.com';
                config.beaconUrlHttps = 'https://col.eum-appdynamics.com';
                config.xd = {enable : false};
            })(window['adrum-config'] || (window['adrum-config'] = {}));
        </script>
@jaroslawhartman
Copy link
Owner

Are you on the latest version? Have you see the #24 ?

Best regards, Jarek

@zontafil
Copy link

zontafil commented Jun 2, 2021

Starting to have problems too since today. I'm on the latest commit.
I get a 403 code though. Will write back if the problems keeps going in the following days

@stynoo
Copy link
Contributor

stynoo commented Jun 2, 2021

I noticed the same, but sporadically. Sometimes Garmin/Cloudflare decides to throw the 'maintenance' error, but eventually my measurements are synced. I am not sure if it is an actual maintenance on the Garmin platform or if it's the security implementation that is blocking the scripts.

@stv0g
Copy link
Collaborator

stv0g commented Jun 3, 2021

Could we fix this with some retry logic?

@stv0g
Copy link
Collaborator

stv0g commented Jun 3, 2021

See also #26

@zontafil
Copy link

zontafil commented Jun 3, 2021

@stv0g At least for me, a retry logic is probably irrelevant, since it's 2 days that I keep having the same problem (also, the script is run 1 time per day, except for some manual run yesterday and today, so I don't think I got banned).

But I guess I'm hijacking this issue since it might be a different thing

@stynoo
Copy link
Contributor

stynoo commented Jun 3, 2021

We could try a retry logic, but I am a bit hesitant to test with it. IF this is the CloudFlare security implementation I won't be surprised if you actually get IP banned when retrying too aggressively. I am also not sure about the Garmin API throttling.

What works for me is to schedule the sync every 2hrs. For now that seems to be the sweet spot.

edit: the scheduled script at 10:00 this morning bugged out with an SS0 403 error code. A manual run 40 minutes later ran successfully.

@stv0g
Copy link
Collaborator

stv0g commented Jun 3, 2021

Thanks for the feedback @stynoo and @m3l7.

What works for me is to schedule the sync every 2hrs. For now that seems to be the sweet spot.

I will add a note to the README.

he scheduled script at 10:00 this morning bugged out with an SS0 403 error code. A manual run 40 minutes later ran successfully.

I would be nice if we could solve #3 . But I dont think Garmin really supports this currently.

Alternatively, we should probably also try to cache our Garmin tokens to avoid a new SSO login every-time the script runs.

@gilabrantes
Copy link

gilabrantes commented Jul 3, 2021

This still happens to me, tried a couple of different IP addresses to rule out being caused by a ban but no joy.

I have it as a cron job to run once per day. Sometimes it works but it seems to be random and very low probability.

On top of this #23 exacerbates the problem, as a rare successful update won't back-fill any of the previously failed ones.

I am on v3.3.1

@ysaliens
Copy link

ysaliens commented Jun 2, 2022

Also having this issue on the very latest code. Haven't been able to get a single good sync since installing this.

@sockRa
Copy link

sockRa commented Jun 7, 2022

I have the same issue. Running a fresh installation. Got 401 on the first sync.

@longstone longstone added bug Something isn't working help wanted Extra attention is needed labels Jun 7, 2022
@prabhupb
Copy link

Leaving this comment if someone comes across this error. In my case, my password had a '&' and hence it was escaped. so you will have to include your password in double quotes. "mypassword&withampersand"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

10 participants