Withings to Garmin Connect

Since a while I’m owning great Withings Scale which has a capability to store measurements in a cloud. Because I’m using Garmin GPSes (and Garmin Connect), I’d love to synchronize the measurements to the Garmin Connect site.

Lucky, I found a great script garmin-withings.

Unfortunately, after latest changes in the Garmin Connect (implementation of SSO on march 2014) the script stopped to work. I’ve compiled changes proposed by https://github.com/cpfair/tapiriik and it seems that the script with my updates works again (well, at least until further changes in Garmin Connect…)

You can find the script on https://github.com/jaroslawhartman/withings-garmin-v2

ToDo

Garmin Connect can display a lot of other parameters, not only weight and body fat level:

Measurements

It would be great to calculate all these figures and post them to Garmin Connect, right? 🙂

Withings to Garmin Connect
Tagged on:         

20 thoughts on “Withings to Garmin Connect

  • 2017-04-15 at 13:06
    Permalink

    Did you notice that this script is not working anymore? It gives me this error message:

    Traceback (most recent call last):
    File “sync.py”, line 125, in
    main()
    File “sync.py”, line 60, in main
    sync(**opts.__dict__)
    File “sync.py”, line 117, in sync
    cookie = garmin.login(garmin_username, garmin_password)
    File “/Users/Cezex/Utilities/Withings2Garmin/garmin.py”, line 132, in login
    cookies = self._get_cookies(email=username, password=password)
    File “/Users/Cezex/Utilities/Withings2Garmin/garmin.py”, line 100, in _get_cookies
    data[“lt”] = re.search(“name=\”lt\”\s+value=\”([^\”]+)\””, preResp.text).groups(1)[0]
    AttributeError: ‘NoneType’ object has no attribute ‘groups’

    Will you be able to fix it?

    Reply
  • 2017-04-26 at 15:42
    Permalink

    Hi.

    I’m trying to run the script, but I’m getting “user EVG has not opened withings data”. As I understand my Withings profile should be public, but I can’t find a wake to make it so, neither in the web interface or in Android app.

    Could you help me with that please?

    Reply
    • 2017-04-26 at 16:16
      Permalink

      Although, I was able to sync by commenting out these three lines:
      if not user.ispublic:
      print ‘user %s has not opened withings data’ % withings_shortname
      return

      Reply
  • 2017-05-19 at 09:25
    Permalink

    This script is not working for me. It gives me this error message:
    ==> Python sync.py – no – upload> weight.fit
    Traceback (most recent call last):
    File “sync.py”, line 126, in
    main()
    File “sync.py”, line 59, in main
    sync(**opts.__dict__)
    File “sync.py”, line 118, in sync
    session = garmin.login(garmin_username, garmin_password)
    File “/Users/aurelio/Desktop/Garmin/withings-garmin/garmin.py”, line 139, in login
    session = self._get_session(email=username, password=password)
    File “/Users/aurelio/Desktop/Garmin/withings-garmin/garmin.py”, line 77, in _get_session
    data[“lt”] = re.search(“name=\”lt\”\s+value=\”([^\”]+)\””, preResp.text).groups(1)[0]
    AttributeError: ‘NoneType’ object has no attribute ‘groups’

    Reply
  • 2017-11-16 at 19:09
    Permalink

    Hi, is this script working for you ? It generated the .fit file, upload to garmin connect but I see no data in garmin. I tried also upload fit file manually with the same result. Any clue ?

    Thanks

    $ ./sync.py –no-upload -v > file.fit
    generating fit file…
    appending weight scale record… 2017-11-16 18:58:01 Nonekg None%
    appending weight scale record… 2017-11-16 18:58:01 Nonekg None%
    appending weight scale record… 2017-11-16 18:58:01 75.15kg 16.713%
    appending weight scale record… 2017-11-16 00:12:32 Nonekg None%
    $

    Reply
    • 2017-11-18 at 21:15
      Permalink

      Hm, can’t really reproduce this issue, even when ran same command:

      generating fit file…
      appending weight scale record… 2017-11-18 08:15:36 Nonekg None%
      appending weight scale record… 2017-11-18 08:15:36 76.891kg 17.259%
      attempting to upload fit file…
      weight.fit has been successfully uploaded!

      What I found strange in your results is multiple lines with Nonekg, especially, the last line. Perhaps this is confusing the script?

      Reply
      • 2017-11-19 at 22:27
        Permalink

        interestingly, I’ve run the script just now and seem to have gone through. maybe it was some temp issue on garmin side 🙂 thanks

        Reply
    • 2019-01-22 at 11:07
      Permalink

      Hi Patrick,

      Thank you for this comment, somehow I’ve overlooked it.

      This is very good initiative! I trust it will find its customers.

      Good luck and best regards,
      Jarek

      Reply
  • 2019-05-31 at 14:19
    Permalink

    I love this script! I’ve never touched Python before, but I managed to make it work. Thank you!
    I’m now trying to import all previous data (last 2 years) and I’m really struggling to set the date range, it’s probably really simple, but I know nothing about python and I’ve been struggling with this for the last hour, can anyone help me out?

    Reply
    • 2019-05-31 at 16:35
      Permalink

      Hi Johan,

      All you need to do is use -f parameter. As per help


      jhartman@wieloryb:~/scripts/withings-garmin-v2$ ./sync.py --help
      Usage: sync.py [options]

      Options:
      -h, --help show this help message and exit
      --garmin-username=, --gu=
      username to login Garmin Connect.
      --garmin-password=, --gp= password to login Garmin Connect.
      -f , --fromdate=
      -t
      , --todate=
      --no-upload Won't upload to Garmin Connect and output binary-
      strings to stdout.
      -v, --verbose Run verbosely

      you can use -f to specify from date, for example:


      jhartman@wieloryb:~/scripts/withings-garmin-v2$ ./sync.py --garmin-username=[username] --garmin-password=[pwd] -f 20170101

      I hope it will help,
      Jarek

      Reply
      • 2019-06-01 at 12:02
        Permalink

        Hi Jarek,

        I had the date format wrong.
        I have my old data in garmin connect down.
        Thank you so much!

        Regrads,

        Johannes

        Reply
  • 2019-07-15 at 15:29
    Permalink

    Hi, I’m getting an error with this every time I try to enter the auth code from the withing website.

    Withings: Get Access Token
    Received error(s):
    invalid_grant: Wrong redirect_uri – Please use same as the one set to get authorization code

    I’ve tried it several times, making sure I’m copying it correctly and doing it within 30 seconds, but it never works.

    Any ideas?

    Reply
    • 2019-07-16 at 10:58
      Permalink

      I’ve checked it on my side and all seems working very fine.

      I believe you’ve changed something with the "callback_url": "https://wieloryb.uk.to/withings/withings.html", but not registered a new app. Suggestion: use same callback URL or follow steps needed to register a new app (but this is more complex).

      Regards,
      Jarek

      Reply
      • 2019-07-16 at 14:55
        Permalink

        Hi Jarek,
        I didn’t change anything. But I tried it on my Windows laptop and it all works fine. When I run it from my QNAP NAS it fails, even though I’m doing exactly the same thing.

        I’m not sure what’s going on. If I copy the WIthings config from the Windows laptop to the QNAP device, it then gets through the Withings authentication but then fails on the Garmin login.

        I have a suspicion that it may be something to do with the Python environment on the QNAP, or a problem with the Requests module, as there were a few warnings installing it on the QNAP.

        Thanks for checking.

        Reply
        • 2019-07-17 at 09:16
          Permalink

          I have a suspicion that it may be something to do with the Python environment on the QNAP, or a problem with the Requests module, as there were a few warnings installing it on the QNAP.

          Indeed, it’s looks like a problem with sending HTTP requests.

          Regards!

          Reply

Leave a Reply to Stuart Cancel reply

Your email address will not be published. Required fields are marked *