Delubear / GlucoseTray

Tray Icon for displaying current BG information in taskbar.
MIT License
35 stars 21 forks source link

No data / Dexcom EU / Germany #62

Closed RufusRed80 closed 2 years ago

RufusRed80 commented 2 years ago

I try to use GlucoseTray with Dexcom, but i get only 0 Data. 2022-06-24_19h46_47

I try US Share 1 and US Share 2 also International. Is the European or German dexcom Clarity not compatible?

amitkumar912 commented 2 years ago

As someone with a US based account, I am also getting similar behavior on all 3 servers.

sgmoore commented 2 years ago

Would you be willing to do some tests?

I don't have a dexcom and I not really familar with how it works, but I did take a look and this is my understanding.

Dexcom have an official and documented API for talking to their servers, but for some reason these methods do not get live details and are delayed by 3 hours. But they have an option in their app that allows you to share your data with other people, so they obviously have an unofficial and undocumented way to getting the live data and someone has worked out how they do that.

Since the official API is pretty much useless for our purpose and most other applications, everybody seems to be used the unofficial way.

Recently it appears that Dexcom have changed something which stops this working. I have come across an article that mentions the changes and I could make some changes.

But unfortunately, since I don't have a dexcom, I can't test this or any changes that I make, which is where I would like you to run some tests.

Could you try running the little program at https://dotnetfiddle.net/HkiqFm and let me know the results. (This runs three little tests, the first being the old method, which I would assume will give some sort of error and the other two are amended versions which I am hoping will work.)

You will need to change a few options at the top of the program to set your username and password and also set the host depending on whether you are in the US or outside (It would appear that share1.dexcom.com is not used any more which is why I only have two options for the host).

Since this method of getting the data relies on the dexcom sharing facility, it may only work if you have enabled sharing in your dexcom app.

So I think you may need to do the following :

Run the dotnet fiddle using your own dexcom username and password.

If either test 2 or test 3 work, then you can stop.

Otherwise, enable sharing on your dexcom app. You may have to add another user at this point (which could be yourself with a second email address).

Re-Run the dotnet fiddle again using your own dexcom username and password.

If either test 2 or test 3 work, then you can stop.

Run the dotnet fiddle again using the username and password for the shared user.

Hopefully one of these will work and if so I could add the changes to GlucoseTray.

Delubear commented 2 years ago

I stopped using the dexcom method a while ago due to it throwing random errors and being inconsistent. I'm guessing their API responses have changed or they've added some other layer of security.

I'm hoping to have some time soon to switch my method back to dexcom and debug it.

For now, if possible, use the NightScout method if you're able to set it up.

Delubear commented 2 years ago

Doing a quick postman test hitting the endpoint to just be able to get the account id is returning a 500 server error.

POST https://share2.dexcom.com/ShareWebServices/Services/General/AuthenticatePublisherAccount Body: accountName : myUsername applicationId : d8665ade-9673-4e27-9ff6-92db4ce13d13 password: myPassword

Response: { "timestamp": 1661638916620, "status": 500, "error": "Internal Server Error", "message": "", "path": "/g5/account/authenticatePatientAccount" }

So not sure if they had a breaking change on their end after updating all their official Share apps to have the appropriate changes to use a new endpoint or to provide more information.

I think they may have removed the few hour data delay using their official API, but it also requires setting up full OAUTH2 AND going through their steps to become a 'full data partner'. https://developer.dexcom.com/scopes-access

Been trying to dig into NightScouts code to see how they access the data now, but no luck so far. The problem is, DexCom doesnt publicly provide any of this information as its more of a backdoor and piggy backing off the door their other apps use.

Delubear commented 2 years ago

Well, first thing is first. Let me put in the code to start grabbing the Account ID as that appears to be the new process, then we pass that as a parameter to the current call we're passing username and password to. Maybe it will work in the context of the application as I might be forgetting something on the fly here.

You can find some relevant discussion here: https://github.com/nightscout/share2nightscout-bridge/pull/48

Delubear commented 2 years ago

Hoping to have a fix for this available tonight. It appears they changed how they return the Trend indicator. It used to be a number, but now it is a string. This was in addition to the authentication changes.

Delubear commented 2 years ago

Please see if it will now work for you in this release: https://github.com/Delubear/GlucoseTray/releases/tag/13.0.0

I've tested with DexCom US and it was working for me.

@RufusRed80 @amitkumar912

amitkumar912 commented 2 years ago

Thanks @Delubear ! Works for me now with the latest release!