diff --git a/README.md b/README.md index 8620819..4cad6fe 100644 --- a/README.md +++ b/README.md @@ -205,6 +205,23 @@ Configure them in `config/withings_app.json`, for example: For the callback URL you will need to setup a webserver hosting `contrib/withings.html`. +To do this in a Docker installation, you can use the environment variable `WITHINGS_APP` to point to a mounted `withings_app.json` + +Example docker-compose: +``` + withings-sync: + container_name: withings-sync + image: ghcr.io/jaroslawhartman/withings-sync:latest + volumes: + - "withings-sync:/root" + - "/etc/localtime:/etc/localtime:ro" + environment: + WITHINGS_APP: /root/withings_app.json +(...) +``` +You can then add the app-config in `withings-sync/withings_app.json` + + ### Run a periodic docker-compose cronjob We take the official docker image and override the entrypoint to crond. diff --git a/withings_sync/withings2.py b/withings_sync/withings2.py index 677bd60..3c2987e 100644 --- a/withings_sync/withings2.py +++ b/withings_sync/withings2.py @@ -67,8 +67,15 @@ def __init__(self): self.user_config[ "authentification_code" ] = self.get_authenticationcode() + try: + self.get_accesstoken() + except Exception as e: + log.warning("Could not get access-token. Trying to renew auth_code") + self.user_config[ + "authentification_code" + ] = self.get_authenticationcode() + self.get_accesstoken() - self.get_accesstoken() self.refresh_accesstoken() @@ -142,6 +149,7 @@ def get_accesstoken(self): "If it's regarding an invalid code, try to start the" " script again to obtain a new link." ) + raise self.user_config["access_token"] = body.get("access_token") self.user_config["refresh_token"] = body.get("refresh_token")