jaroslawhartman/withings-sync

withings_sync.garmin.APIException: SSO error 401

midzelis opened this issue · 11 comments

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>

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

Best regards, Jarek

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

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 commented

Could we fix this with some retry logic?

stv0g commented

See also #26

@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

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 commented

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.

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

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

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