nightscout / nightscout-connect

Single entry point for bridging cloud resources containing diabetes data to Nightscout.
GNU Affero General Public License v3.0
31 stars 31 forks source link

[GLOOKO] Problem with nightscout-connect using European Glooko account #14

Open fjpezuela opened 11 months ago

fjpezuela commented 11 months ago

I am trying to connect to a European Glooko account from Spain, and I get an error when connecting. Here are the logs from Nightscout:

2023-08-05T18:23:30.513865455Z stdout F MiniMed Connect not enabled 2023-08-05T18:23:26.821569259Z stdout F Executing setupMMConnect 2023-08-05T18:23:26.821517826Z stdout F Dexcom bridge not enabled 2023-08-05T18:23:25.015052031Z stdout F Executing setupBridge 2023-08-05T18:23:24.819624981Z stdout F } 2023-08-05T18:23:24.819622748Z stdout F kind: 'glooko' 2023-08-05T18:23:24.819620799Z stdout F baseURL: 'https://eu.api.glooko.com';, 2023-08-05T18:23:24.819619004Z stdout F glookoTimezoneOffset: -7200000, 2023-08-05T18:23:24.819617002Z stdout F glookoPassword: '*****', 2023-08-05T18:23:24.819614804Z stdout F glookoEmail: '**@gmail.com', 2023-08-05T18:23:24.819612086Z stdout F glookoServer: 'eu.api.glooko.com', 2023-08-05T18:23:24.819609229Z stdout F glookoEnv: 'eu', 2023-08-05T18:23:24.819593054Z stdout F INPUT PARAMS { kind: 'glooko' } { 2023-08-05T18:23:24.819203689Z stdout F GLOOKO using ms offset: -7200000 2

2023-08-05T18:23:43.195213184Z stdout F } 2023-08-05T18:23:43.195211094Z stdout F response: [Object] 2023-08-05T18:23:43.195208838Z stdout F request: [ClientRequest], 2023-08-05T18:23:43.195206737Z stdout F config: [Object], 2023-08-05T18:23:43.195204564Z stdout F code: 'ERR_BAD_REQUEST', 2023-08-05T18:23:43.195202226Z stdout F at processTicksAndRejections (node:internal/process/task_queues:83:21) { 2023-08-05T18:23:43.195199974Z stdout F at endReadableNT (node:internal/streams/readable:1358:12) 2023-08-05T18:23:43.195195974Z stdout F at Unzip.emit (node:events:525:35) 2023-08-05T18:23:43.19519297Z stdout F at Unzip.handleStreamEnd (/workspace/node_modules/nightscout-connect/node_modules/axios/dist/node/axios.cjs:2989:11) 2023-08-05T18:23:43.195188961Z stdout F at settle (/workspace/node_modules/nightscout-connect/node_modules/axios/dist/node/axios.cjs:1909:12) 2023-08-05T18:23:43.195184914Z stdout F data: AxiosError: Request failed with status code 422 2023-08-05T18:23:43.195180833Z stdout F type: 'AUTHENTICATION_ERROR',

burnedikt commented 11 months ago

Hi, I also had some issues getting the eu servers to work and in the end, the following config worked for me. It seems like there's yet another server for germany / france so I had to replace eu.api.glooko.com by de-fr.api.glooko.com. Unsure were Spain is hosted, though.

CONNECT_SOURCE=glooko
CONNECT_GLOOKO_ENV=eu
CONNECT_GLOOKO_SERVER=de-fr.api.glooko.com
CONNECT_GLOOKO_EMAIL=<glooko-useraccount-email>
CONNECT_GLOOKO_PASSWORD=<glooko-useraccount-password>
CONNECT_GLOOKO_TIMEZONE_OFFSET=1
fjpezuela commented 11 months ago

de-fr.api.glooko.com

2023-08-08T06:34:49.820874039Z stdout F FRAME ERROR 2023-08-08T06:34:49.819681626Z stdout F } 2023-08-08T06:34:49.819679517Z stdout F } 2023-08-08T06:34:49.819677664Z stdout F } 2023-08-08T06:34:49.819675802Z stdout F response: [Object] 2023-08-08T06:34:49.819673853Z stdout F request: [ClientRequest], 2023-08-08T06:34:49.819671923Z stdout F config: [Object], 2023-08-08T06:34:49.81966995Z stdout F code: 'ERR_BAD_REQUEST', 2023-08-08T06:34:49.81966812Z stdout F at processTicksAndRejections (node:internal/process/task_queues:83:21) { 2023-08-08T06:34:49.819666213Z stdout F at endReadableNT (node:internal/streams/readable:1358:12) 2023-08-08T06:34:49.819663577Z stdout F at Unzip.emit (node:events:525:35) 2023-08-08T06:34:49.819661685Z stdout F at Unzip.handleStreamEnd (/workspace/node_modules/nightscout-connect/node_modules/axios/dist/node/axios.cjs:2989:11) 2023-08-08T06:34:49.819658451Z stdout F at settle (/workspace/node_modules/nightscout-connect/node_modules/axios/dist/node/axios.cjs:1909:12) 2023-08-08T06:34:49.819655352Z stdout F data: AxiosError: Request failed with status code 401 2023-08-08T06:34:49.81965311Z stdout F type: 'AUTHENTICATION_ERROR', 2023-08-08T06:34:49.819650716Z stdout F event: { 2023-08-08T06:34:49.819648807Z stdout F },

Thank you very much for your reply.

With the server you indicated, it shows a 401 error (invalid credentials). The credentials are correct. I think the server in Spain must be a different one.

Thank you very much.

burnedikt commented 11 months ago

You should be able to find out the correct url if you log into the glooko website and check the network tab of the browser's developer tool. There should be a bunch of requests going towards glooko's server.

fjpezuela commented 11 months ago
image

I have checked the domain that opens when logging in to the Glooko site, and it uses the domain eu.my.glooko.com, but it still gives error 422.

fjpezuela commented 11 months ago
image

I have also tried eu.api.glooko.com, but it also gives error 422.

fjpezuela commented 11 months ago

I add an analysis of a Glooko web login, in case it helps. I have hidden some data.

<!DOCTYPE html>

LogbookWeb

`

webwude commented 11 months ago

I have the same issue. If I add "CONNECT_GLOOKO_ENV=eu" or eu.api.google.com as server (as this is shown in the browser details as well, I get an 422 authentification error. If I remove all eu flags, I get an authentification error as well, with code 401.

Snipplet from container manager / docker on my Synology (sorry for the strange encoding):


<html><body>
<!--StartFragment-->

2023/08/17 11:11:18 | stdout | event: { type: 'SESSION_ERROR' }
-- | -- | --
2023/08/17 11:11:18 | stdout | },
2023/08/17 11:11:18 | stdout | elapsedWaiting: 8
2023/08/17 11:11:18 | stdout | endedWaiting: 1692263478221,
2023/08/17 11:11:18 | stdout | startedWaiting: 1692263478213,
2023/08/17 11:11:18 | stdout | started: 1692263478213,
2023/08/17 11:11:18 | stdout | diagnostics: {},
2023/08/17 11:11:18 | stdout | last_known: null,
2023/08/17 11:11:18 | stdout | session: null,
2023/08/17 11:11:18 | stdout | duration: 0,
2023/08/17 11:11:18 | stdout | retries: 0,
2023/08/17 11:11:18 | stdout | context: {
2023/08/17 11:11:18 | stdout | {
2023/08/17 11:11:18 | stdout | FRAME ERROR
2023/08/17 11:11:18 | stdout | }
2023/08/17 11:11:18 | stdout | }
2023/08/17 11:11:18 | stdout | }
2023/08/17 11:11:18 | stdout | response: [Object]
2023/08/17 11:11:18 | stdout | request: [ClientRequest],
2023/08/17 11:11:18 | stdout | config: [Object],
2023/08/17 11:11:18 | stdout | code: 'ERR_BAD_REQUEST',
2023/08/17 11:11:18 | stdout |     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
2023/08/17 11:11:18 | stdout |     at endReadableNT (node:internal/streams/readable:1345:12)
2023/08/17 11:11:18 | stdout |     at Unzip.emit (node:events:539:35)
2023/08/17 11:11:18 | stdout | at Unzip.handleStreamEnd (/opt/app/node_modules/nightscout-connect/node_modules/axios/dist/node/axios.cjs:2989:11)
2023/08/17 11:11:18 | stdout | at settle (/opt/app/node_modules/nightscout-connect/node_modules/axios/dist/node/axios.cjs:1909:12)
2023/08/17 11:11:18 | stdout | data: AxiosError: Request failed with status code 422
2023/08/17 11:11:18 | stdout | type: 'AUTHENTICATION_ERROR',
2023/08/17 11:11:18 | stdout | event: {
2023/08/17 11:11:18 | stdout | },
2023/08/17 11:11:18 | stdout | failures: 0
2023/08/17 11:11:18 | stdout | authorization_errors: 0,
2023/08/17 11:11:18 | stdout | authorizations: 0,
2023/08/17 11:11:18 | stdout | authentication_errors: 1,
2023/08/17 11:11:18 | stdout | authentications: 0,
2023/08/17 11:11:18 | stdout | sessions: 0,
2023/08/17 11:11:18 | stdout | retries: 0,

<!--EndFragment-->
</body>
</html>
'''
atomphil commented 11 months ago

I have the same problem, my variables are as follows:

CONNECT_SOURCE = glooko CONNECT_GLOOKO_EMAIL = **@gmx.de CONNECT_GLOOKO_PASSWORD = ! CONNECT_GLOOKO_SERVER = de-fr.my.glooko.com CONNECT_GLOOKO_ENV = eu CONNECT_GLOOKO_TIMEZONE_OFFSET = 2

This results in a status code 422 'AUTHENTICATION_ERROR'

Same for CONNECT_GLOOKO_SERVER = de-fr.api.glooko.com With CONNECT_GLOOKO_SERVER = eu.api.glooko.com I get error code 401

2023-08-21T14:21:22.134976391Z stdout F   context: {
2023-08-21T14:21:22.134943961Z stdout F {
2023-08-21T14:21:22.04220788Z stdout F FRAME ERROR
2023-08-21T14:21:22.040628159Z stdout F }
2023-08-21T14:21:22.04062454Z stdout F   }
2023-08-21T14:21:22.040620788Z stdout F     }
2023-08-21T14:21:22.040616998Z stdout F       response: [Object]
2023-08-21T14:21:22.040613173Z stdout F       request: [ClientRequest],
2023-08-21T14:21:22.040609565Z stdout F       config: [Object],
2023-08-21T14:21:22.040605899Z stdout F       code: 'ERR_BAD_REQUEST',
2023-08-21T14:21:22.040602397Z stdout F         at processTicksAndRejections (node:internal/process/task_queues:83:21) {
2023-08-21T14:21:22.040599014Z stdout F         at endReadableNT (node:internal/streams/readable:1358:12)
2023-08-21T14:21:22.040595241Z stdout F         at Unzip.emit (node:events:525:35)
2023-08-21T14:21:22.040591334Z stdout F         at Unzip.handleStreamEnd (/workspace/node_modules/nightscout-connect/node_modules/axios/dist/node/axios.cjs:2989:11)
2023-08-21T14:21:22.040586932Z stdout F         at settle (/workspace/node_modules/nightscout-connect/node_modules/axios/dist/node/axios.cjs:1909:12)
2023-08-21T14:21:22.040582709Z stdout F     data: AxiosError: Request failed with status code 422
2023-08-21T14:21:22.040578421Z stdout F     type: 'AUTHENTICATION_ERROR',
2023-08-21T14:21:22.040574534Z stdout F   event: {
2023-08-21T14:21:22.040571402Z stdout F   },
2023-08-21T14:21:22.040567827Z stdout F     failures: 0
2023-08-21T14:21:22.040564629Z stdout F     authorization_errors: 0,
2023-08-21T14:21:22.040561648Z stdout F     authorizations: 0,
2023-08-21T14:21:22.040558238Z stdout F     authentication_errors: 1,
2023-08-21T14:21:22.040554779Z stdout F     authentications: 0,
2023-08-21T14:21:22.04055104Z stdout F     sessions: 0,
2023-08-21T14:21:22.040547558Z stdout F     retries: 0,

`

bewest commented 11 months ago

Would someone be willing to send me an email at bewest at gmail.com or medicaldatnetworks.com? Please mention nightscout-connect and glooko in the subject line. It would be great to try accessing a temporary password in my development environment to test.

peisenh commented 10 months ago

Also struggling with

CONNECT_GLOOKO_SERVER = de-fr.api.glooko.com

and getting 422 status code if the right email and password is used, 401 with incorrect login.

I am little bit confused about the API. Is it even possible for a "normal" Glooko user to use the API directly or is this only possible for commercial customers who registered as developers? See: https://developers.glooko.com/docs/directintegrations/registration

Question to the people which are able to use this: Are you a "normal" glooko user or registered developer? (regardless of region)

webwude commented 10 months ago

Would someone be willing to send me an email at bewest at gmail.com or medicaldatnetworks.com? Please mention nightscout-connect and glooko in the subject line. It would be great to try accessing a temporary password in my development environment to test.

I could help. But as mentioned, I have a more complicated setup: my nightscout installation is on a docker on my synology NAS - I do not have direct access to the installation, only via installing an updated docker image and setting the config values.

peisenh commented 10 months ago

I am stuck here. Was somebody able to use this on the de-fr servers from glooko?

webwude commented 10 months ago

I am stuck here. Was somebody able to use this on the de-fr servers from glooko?

I am not aware of anybody from EU. On the other hand: if somebody is able, would he / she check issues on Github?

bjornoleh commented 9 months ago

Hi, I also had some issues getting the eu servers to work and in the end, the following config worked for me. It seems like there's yet another server for germany / france so I had to replace eu.api.glooko.com by de-fr.api.glooko.com. Unsure were Spain is hosted, though.

CONNECT_SOURCE=glooko
CONNECT_GLOOKO_ENV=eu
CONNECT_GLOOKO_SERVER=de-fr.api.glooko.com
CONNECT_GLOOKO_EMAIL=<glooko-useraccount-email>
CONNECT_GLOOKO_PASSWORD=<glooko-useraccount-password>
CONNECT_GLOOKO_TIMEZONE_OFFSET=1

Hi @burnedikt , do you happen to know details about server / env settings for Scandinavian users (Norway / Sweden)?

Thanks!

webwude commented 9 months ago

@bjornoleh tried your settings, still the same error :(

bjornoleh commented 9 months ago

@bjornoleh tried your settings, still the same error :(

Those were not my settings, I was replying to the post by burnedikt :-)

bewest commented 9 months ago

If you are logged into the Glooko web interface, you can use the browser inspector and network tools to see which servers are being used. We can add that information to the repository here.

bjornoleh commented 9 months ago

If you are logged into the Glooko web interface, you can use the browser inspector and network tools to see which servers are being used. We can add that information to the repository here.

Thanks! I did have a go at that, but didn’t quite know my way around the source inspector in Chrome. I am trying again now.

I am seeing:

https://eu.my.glooko.com https://eu.api.glooko.com

@bewest , Anything else I should look for?

rosserl commented 8 months ago

Hey there, I did some reverse engineering and found this deviceInformation fields, and signing in works for me with these values (via eu.api.glokoo.com):

    "deviceInformation": {
        "applicationType": "logbook",
        "os": "android",
        "osVersion": "33",
        "device": "Google Pixel 4a",
        "deviceManufacturer": "Google",
        "deviceModel": "Pixel 4a",
        "serialNumber": "ab43bfjdj3423421fb",
        "clinicalResearch": false,
        "deviceId": "716c34bac673f4b9",
        "applicationVersion": "6.1.3",
        "buildNumber": "0",
        "gitHash": "g4fbed2011b"
    }

The only field actually needed is applicationType, which can be "kiosk" or "logbook" - both work. Although I would set the other fields too, so they could not detect it not being the app. (deviceId and serial are random in my example above, version/build/git hash are form the latest play store version).

@bewest ^^

peisenh commented 8 months ago

And we have a winner here! Thanks! :-)

I am using the values you send, did some random deviceId and serialNumber instead the above in your example. Then with:

export CONNECT_SOURCE=glooko export CONNECT_GLOOKO_SERVER=de-fr.api.glooko.com

(for germany)

I am now able to get values from glooko and feed them to nightscout.

At least current glucose level and basal seem to work at first glance.

Thanks again.

webwude commented 8 months ago

Where do I put the values? Where can I insert them? I am using a docker image for nightscout on Synology.

bjornoleh commented 8 months ago

Where do I put the values? Where can I insert them? I am using a docker image for nightscout on Synology.

Along with other configuration variables, probably in docker-compose.yml or similar

peisenh commented 8 months ago

At the moment: This is hard coded in lib/sources/glooko/index.js, so you need to edit the source. Look for ... "deviceInformation": { "deviceModel": "iPhone" } ... This needs to be replaced by the segment above. Of cause you need to be able to run modified code on your nightscout instance, so consider this only as a proof of concept or temporary solution.

In the long term: To be able to use configuration variables the source must be patched accordingly to allow this.

I am quite busy now - maybe can provide a PR in the next 2 week for this. If somebody has some more time to work earlier on this: Please feel free. This will help all of us.

funkstille commented 8 months ago

Just tried it with nightscout version "15.0.2 head", as it is, no modfications. Works fine with glooko Account from Germany.

Used the following variables:

ENABLE=careportal basal food iob bwp cage sage iage bage pushover pump cors cob bridge Boluscalc connect CONNECT_SOURCE=glooko CONNECT_GLOOKO_SERVER=de-fr.api.glooko.com CONNECT_GLOOKO_EMAIL=email CONNECT_GLOOKO_PASSWORD=password CONNECT_GLOOKO_TIMEZONE_OFFSET=1

It only retrieves the bolus (carbs and insulin) and basal, no cgm data. But that is fine for since I get those from xdrip companion.

webwude commented 8 months ago

Just tried it with nightscout version "15.0.2 head", as it is, no modfications. Works fine with glooko Account from Germany.

Just tried - used the posted settings - still 401 error (authentification) :(

peisenh commented 8 months ago

It only retrieves the bolus (carbs and insulin) and basal, no cgm data. But that is fine for since I get those from xdrip companion.

Same here. Did forget I had xdrip running - so the cgm was indeed coming from xdrip instead from glooko. Did not find I way to retrieve the cgm data via api so far.

So at the moment:

zehnBE commented 8 months ago

Looks, that the folloging changes helps:


diff --git a/gluko/lib/sources/glooko/index.js b/gluko/lib/sources/glooko/index.js
index 010e0c87..7deba045 100644
--- a/gluko/lib/sources/glooko/index.js
+++ b/gluko/lib/sources/glooko/index.js
@@ -51,7 +51,18 @@ function login_payload (opts) {
       "password": opts.glookoPassword
     },
     "deviceInformation": {
-      "deviceModel": "iPhone"
+        "applicationType": "logbook",
+        "os": "android",
+        "osVersion": "33",
+        "device": "Google Pixel 4a",
+        "deviceManufacturer": "Google",
+        "deviceModel": "Pixel 4a",
+        "serialNumber": "ab43bfjdj3423421fb",
+        "clinicalResearch": false,
+        "deviceId": "716c34bac673f4b9",
+        "applicationVersion": "6.1.3",
+        "buildNumber": "0",
+        "gitHash": "g4fbed2011b"
     }
   };
   return body;
Heiner1 commented 8 months ago

Next good news: It's running with zehnBE changes.
I hope it's a solution for all.

rosserl commented 8 months ago

I'd like to point out one more time, that each user should configure a different deviceId and serialNumber (and maybe also the device), so glooko can't filter out these requests as easy.

AlexM4H commented 8 months ago

@Heiner1 Is the Patch still working for you?

I think I might be doing something wrong. No requests are being sent to de-fr.api.glooko.com at all.

I have connect enabled and use nightscout-latest-dev and the patched nightscout-connect version. What else could I have forgotten?

'nightscout-connect capture' at least provides the personal data such as name and date of birth

Heiner1 commented 8 months ago

@rosserl

I'd like to point out one more time, that each user should configure a different deviceId and serialNumber (and maybe also the device), so glooko can't filter out these requests as easy.

Good idea! But before the content was only "deviceModel": "iPhone"; I think it's also possible that Glooko would be alarmed about this.

@AlexM4H Yes it's still working; unfortunately I have nightscout running at 10be, so I've limited overview about zehnBEs server configuration. If you're living in Germany you should also ask funkstille, because he was not forced to change "deviceInformation“. Maybe it has something to do where servers are located, he uses railway.

AlexM4H commented 8 months ago

@rosserl

I'd like to point out one more time, that each user should configure a different deviceId and serialNumber (and maybe also the device), so glooko can't filter out these requests as easy.

Good idea! But before the content was only "deviceModel": "iPhone"; I think it's also possible that Glooko would be alarmed about this.

@AlexM4H Yes it's still working; unfortunately I have nightscout running at 10be, so I've limited overview about zehnBEs server configuration. If you're living in Germany you should also ask funkstille, because he was not forced to change "deviceInformation“. Maybe it has something to do where servers are located, he uses railway.

Thx a lot. I will asked him. I used a docker image on a hetzner cloud server.

rosserl commented 8 months ago

@rosserl

I'd like to point out one more time, that each user should configure a different deviceId and serialNumber (and maybe also the device), so glooko can't filter out these requests as easy.

Good idea! But before the content was only "deviceModel": "iPhone"; I think it's also possible that Glooko would be alarmed about this.

Yes, but then you could remove all of that data, except for applicationType , which s the only required field. (So there would be no improvement in regards to detection by glooko, but also no unnecessary stuff.)

AlexM4H commented 8 months ago

It seems to be a bit more complicated. In my case, the data is transferred from CamAPS to Glooko. The bolus rates are also included in the Glooko reports. However, they may not be transferred via the API. I will take a closer look tomorrow.

atomphil commented 8 months ago

My Nightscout is running on Northflank. I just forked the repository and used Buildpack to build a container. As a result, nightscout-connect is only included as a Nightscout plugin. How can I apply the patch in this configuration? Or is there a way to run nightscout-connect in a Docker container? Is there perhaps already a suitable docker-compose.yml?

lucienimmink commented 8 months ago

Same issue here. Created a PR for the patch above (https://github.com/nightscout/nightscout-connect/pull/31) I've replaced the 2 IDs by a function that generates the IDs at random.

Extra info: My nightscout runs in a container inside my synology NAS. Glooko account it used for uploading data from a T:slim x2 pump (which has no active mobile app in the EU yet!) which makes me think: should we capture/use a desktop grade device instead of a mobile one?

bewest commented 8 months ago

Thanks, looking good! Has anyone experimented with other values? For example, it might be nice to attribute nightscout-connect and a stable device id for the entire runtime. It might be nice to optionally read these values from the incoming configuration. This would enable changing the values using environment variables, which can give some relief from needing to change the code in the case where Glooko implements a trivial change.

peisenh commented 8 months ago

I am able to get data with the patch and feed it to nightscout - however I am only getting bolus/basal/carb values but no values from CGM. It this working for somebody?

funkstille commented 8 months ago

No CGM is not working / supported so far. If you are using camAPS you can use xDrip in companion mode for CGM.

AlexM4H commented 8 months ago

What is the graph API (v3) command all about? I found it commented out in the source code.

lucienimmink commented 7 months ago

...so this is it? What's needed to get this going?

sircsaba commented 1 month ago

I'm using NS 14.2.6 image on Docker with Portainer on a Raspberry Pi 4 . Where do I put the information to get glooko working please ?