timoschlueter / nightscout-librelink-up

Script written in TypeScript that uploads CGM readings from LibreLink Up to Nightscout.
MIT License
200 stars 252 forks source link

TypeError: Cannot read properties of undefined (reading 'token') #28

Closed job-bens closed 7 months ago

job-bens commented 2 years ago

Hi, Thanks for your work, I would like use, but I don't understand What's happen... But It doesn't work, I must be making a mistake somewhere...

Capture d’écran 2022-03-03 à 19 50 13
timoschlueter commented 2 years ago

Hi @job-bens, can you please provide the environment variables that you have set on the plugin? You can obfuscate them obviously. I just what to make sure that you have set the required variables correctly :)

job-bens commented 2 years ago

Hi, @timoschlueter,

Of Course,

Capture d’écran 2022-03-03 à 21 17 20 Capture d’écran nightscoot Capture d’écran swager

I don't know what's I need to use in the Swagger, Api Secret or the token in url, and how fill it ?

microspock commented 2 years ago

Hi here, i have the same "token" problem, and i live in France too, like job-bens. I think it's more librelink up related than nightscout.

edit: maybe a clue, I've checked the libreview website, the API adress start with api-fr and not api-eu for french based users but i think it's not the problem.

job-bens commented 2 years ago

@timoschlueter Any idea ?

isabellepeinture commented 2 years ago

Same here, I have the same error TypeError: Cannot read properties of undefined (reading 'token') I live also in France if that changes anything. setuplink

fabricejoubert commented 2 years ago

Hello, Did you find a solution ? I also live in France and I have got the same error message....

I would like to use the fsl3 with android aps and for the moment it seems to be the only solution to recover the blood sugar values.

Thanks in advance

job-bens commented 2 years ago

Malheureusement non, j ai abandonné l idée

Le mar. 7 juin 2022 à 11:45, fabricejoubert @.***> a écrit :

Hello, Did you find a solution ? I also live in France and I have got the same error message....

I would like to use the fsl3 with android aps and for the moment it seems to be the only solution to recover the blood sugar values.

Thanks in advance

— Reply to this email directly, view it on GitHub https://github.com/timoschlueter/nightscout-librelink-up/issues/28#issuecomment-1148443871, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANVOIYXJ6Z7BAYVLFZ6DIVTVN4K37ANCNFSM5P4TOVHQ . You are receiving this because you were mentioned.Message ID: @.***>

fabricejoubert commented 2 years ago

Bonjour,

Pour information cette fonctionnalité vient d'être implémentée dans la dernière version xdrip et ça fonctionne très bien. Xdrip récupère directement les données libreview.

https://xdrip.readthedocs.io/en/latest/install/webfollower/

zanfirovidius commented 2 years ago

Hello,

I have the same error message and in order to fix it, I had to switch to this LIBRE_LINK_UP_URL=api-fr.libreview.io. And using this URL are able to login in and get all the data about the patient. Now the problem is that (at last for what there is in the main branch) after receiving the blood glucose measurement items I receive a really strange error. Any suggestions? (for the moment I am using something that I forked 3 or 4 months ago)

UPDATE: Funny thing: from time to time it does update the values in the Nightscout, but the update will happen sometimes after 5 minutes other times after 15 min (really random intervals)

<!DOCTYPE html>\n\t<html>\n\t <head>\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t<meta charset=\"utf-8\">\n\t\t<title>Application Error</title>\n\t\t<style media=\"screen\">\n\t\t html,body,iframe {\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t }\n\t\t html,body {\n\t\t\theight: 100%;\n\t\t\toverflow: hidden;\n\t\t }\n\t\t iframe {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tborder: 0;\n\t\t }\n\t\t</style>\n\t </head>\n\t <body>\n\t\t<iframe src=\"//www.herokucdn.com/error-pages/application-error.html\"></iframe>\n\t </body>\n\t</html>

timoschlueter commented 2 years ago

@zanfirovidius i noticed that on my instance as well. I will take a look at this.

zanfirovidius commented 2 years ago

Hello. Quick question.... dose any of you have issue with receiving data from the LibreLink server? (personaly I am using the fr server for my kid). For the last 5 days I received data only at random intervals and starting from today I am not able to receive any data. (and is not link to nightscout-librelink-up, because also the LibreLinkUp app is not receiving data) Any info will be useful because we are struggling with monitoring my kids blood sugar

marcograwunder commented 2 years ago

Hello. Quick question.... dose any of you have issue with receiving data from the LibreLink server? (personaly I am using the fr server for my kid). For the last 5 days I received data only at random intervals and starting from today I am not able to receive any data. (and is not link to nightscout-librelink-up, because also the LibreLinkUp app is not receiving data) Any info will be useful because we are struggling with monitoring my kids blood sugar

No problems here. Maybe the data is not sent to the libre link servers at all? We sometimes need to restart the smartphone of our son to activate data sending again…

zanfirovidius commented 2 years ago

Hello. Quick question.... dose any of you have issue with receiving data from the LibreLink server? (personaly I am using the fr server for my kid). For the last 5 days I received data only at random intervals and starting from today I am not able to receive any data. (and is not link to nightscout-librelink-up, because also the LibreLinkUp app is not receiving data) Any info will be useful because we are struggling with monitoring my kids blood sugar

No problems here. Maybe the data is not sent to the libre link servers at all? We sometimes need to restart the smartphone of our son to activate data sending again…

Thank you. I ended up uninstalling and reinstalling the app. It works now. Thank you again.

timoschlueter commented 2 years ago

Hello,

I have the same error message and in order to fix it, I had to switch to this LIBRE_LINK_UP_URL=api-fr.libreview.io. And using this URL are able to login in and get all the data about the patient. Now the problem is that (at last for what there is in the main branch) after receiving the blood glucose measurement items I receive a really strange error. Any suggestions? (for the moment I am using something that I forked 3 or 4 months ago)

UPDATE: Funny thing: from time to time it does update the values in the Nightscout, but the update will happen sometimes after 5 minutes other times after 15 min (really random intervals)

<!DOCTYPE html>\n\t<html>\n\t <head>\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t<meta charset=\"utf-8\">\n\t\t<title>Application Error</title>\n\t\t<style media=\"screen\">\n\t\t html,body,iframe {\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t }\n\t\t html,body {\n\t\t\theight: 100%;\n\t\t\toverflow: hidden;\n\t\t }\n\t\t iframe {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tborder: 0;\n\t\t }\n\t\t</style>\n\t </head>\n\t <body>\n\t\t<iframe src=\"//www.herokucdn.com/error-pages/application-error.html\"></iframe>\n\t </body>\n\t</html>

I published version 1.8.0 of the app where you can set the LINK_UP_REGION environment variable to specify the API endpoint the app should use. In your case, setting the variable to "FR" will set the LIBRE_LINK_UP_URL to api-fr.libreview.io. This should help with the manual overwrite of the variable in the code :) Seems like there are many more API endpoints dedicated to specific regions von Abbotts end. I found an API endpoint to receive all of them and added them to the app: https://github.com/timoschlueter/nightscout-librelink-up/blob/main/utils/llu-api-endpoints.js

artempartos commented 2 years ago

Got the same message yesterday, any thoughts?

UPD, changed url to DE, seems working fine, thanks everybody

ezepizarro commented 2 years ago

Hello, I am getting the same error. Not sure if I am missing something.

2022-07-14T15:54:00.621399+00:00 app[worker.1]: [info]: Logged in to LibreLink Up
2022-07-14T15:54:00.659272+00:00 app[worker.1]: [error]: {"message":"invalid or expired jwt"}
2022-07-14T15:54:00.660459+00:00 app[worker.1]: [error]: getting libreLinkUpConnection:  Cannot read properties of undefined (reading 'data')

I tried with EU, FR, and DE.

khskekec commented 2 years ago

I just fixed this in my client this morning. The response if you are using a specific server answers with redirect information.

Could you just try out to set LIBRE_LINK_UP_URL to api.libreview.io.

@timoschlueter I think it is not necessary to use region information at all. You can directly use api.libreview.io without and simplify the configuration for the users.

ezepizarro commented 2 years ago

@khskekec I tried, same error. I manually hit the API endpoints, and I am able to get the token, but hitting the connections endpoint is returning that error. Could it be that they changed the way that you authenticate?

khskekec commented 2 years ago

No, my client application also include authentication procedures and I did not change anything in the code.

The only thing I changed was the api url to api.libreview.io.

I do not think that changes are necessary here.

ezepizarro commented 2 years ago
2022-07-14T19:39:00.791033+00:00 app[worker.1]: [info]: renew token
2022-07-14T19:39:00.964734+00:00 app[worker.1]: [info]: Logged in to LibreLink Up

2022-07-14T19:39:00.964786+00:00 app[worker.1]: [debug]: authenticatedHttpHeaders: {"User-Agent":"FreeStyle LibreLink Up NightScout Uploader","Content-Type":"application/json","version":"4.2.2","product":"llu.ios","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Pragma":"no-cache","Cache-Control":"no-cache","authorization":"Bearer <TOKEN-DELETED>"}

2022-07-14T19:39:00.975609+00:00 app[worker.1]: [error]: {"message":"invalid or expired jwt"}
2022-07-14T19:39:00.975821+00:00 app[worker.1]: [error]: getting libreLinkUpConnection:  Cannot read properties of undefined (reading 'data')

It's not been able to authenticate when it calls the connections endpoint. I live in the Netherlands, just in case.

nils-evert commented 2 years ago

Just in case you did not get this email (it is available as a web version, too) I wanted to give this as an additional information.

https://service.freestylelibre.se/optiext/optiextension.dll?ID=qYZqW272h0U8aC30UCtxz%2BN_o66DhGuEh5IWxsI47PuRGaXazQjPjck1Rr7B%2BTEenpMiYru3AqvKB_pW0jy3GXuRUW%2Ba1

It's in swedish but google translator couldn't handle it 🤪 (I wanted to translate to German)

Some people may need to delete their accounts and create a new one as far as I understood.

ezepizarro commented 2 years ago

@useful-idiot I didn't get that email, that's probably what is going on with my account. I don't want to delete the main account and miss all the information, I will see how can I work around it if it's possible. Thanks!

timoschlueter commented 2 years ago

@gui-dos awesome observation! i didn't notice that when i looked at the traffic. I will check if we can use this mechanism to automatically find the correct API endpoint.

ezepizarro commented 2 years ago

Now is working for me, thanks all!

timoschlueter commented 2 years ago

Whats interesting here is: If the config-Endpoint does not need any authentication but the assumption that it does in fact return the API endpoint that you have to use is correct, how does Abbott decide which endpoint you need to access? Some kind of IP based geolocation? Or the HTTP header? Any idea, @gui-dos? :)

For now, the endpoints are hardcoded in the application as of version 1.8.0. A generic approach would be way better!

khskekec commented 2 years ago

As I said :

I am sitting in Germany and directly communicate with api.libreview.io without any problems.

I am not sure about performance and response times but it works.

It seems to me that it is not necessary to specify the local server address.

khskekec commented 2 years ago

@gui-dos

In my opinion this is just fine and the service ist responsible for proper routing and redirecting.

But this definetly simplifies the configuration for users. In comparison to dexcom, which requires the usage of regional server, abbot does not care about it it seems.

I am not sure whether responses differ in general but actually it is guaranteed that most recent cgm readings are available. This should be totally okay for this bridge.

timoschlueter commented 2 years ago

I really like the discussion with you guys. Thank you all! :)

@khskekec I am sitting in Germany as well and just tried using the generic endpoint from Germany via a VPN connection going through Spain, just to confirm your theory of routing. When connecting from outside of Germany (through the VPN), the generic login endpoint seems to determine that the request comes in fact from Spain and gives a response with a HTTP 200 and redirect information, although it does not do the redirection itself:

{
    "status": 0,
    "data": {
        "redirect": true,
        "region": "de"
    }
}

Using the German API endpoint through the Spanish VPN works still fine. You are right, there is routing on Abbotts side. But I am not quite sure if we should switch to the generic endpoint for all users. A thought I have: If I spin up a Heroku instance in Spain for example, but am in fact using a German account, won't the generic endpoint respond with a redirection as well instead of the actual measurements? The only solution for me would be to specify the region in order to receive measurements. Or this bridge should figure out the correct API itself. What are your thoughts? Am I missing something?

khskekec commented 2 years ago

Hey @timoschlueter,

Nice catch!

I find your idea great to let the bridge talk to the main api.libreview.io and do the reset of the host if the service responds with some redirect information instead of an access token.

I will definetly implement this in my client also.

The interesting part for me is the way abbot handles the routing:

I am sitting in Germany and have an account belonging to Germany - > I can talk with api.libreview.io

I am sitting in Spain and have an account belonging to Germany - > I cannot talk with api.libreview.io and receive redirect information...

Is that correct?

AidasK commented 2 years ago

It worked when I changed my region from DE to GB. So I would suggest everyone to test out different regions despite your country.

kaussel commented 2 years ago

Hi everybody,

maybe only somehow related to this problem. I have had the same problem with "TypeError: Cannot read... token" and solved it with all the help above.

Before that I used a different librelinkup-to-nightscout repo deployed by heroku and had glucose measurements uploaded every minute. Thereafter every 5 minutes (which is fine). But for two days now I seem to miss 2 of 3 measurements or do not get them. So I only receive a single value every 15 minutes (which definitely is not fine). I also encounter the dreaded "---" (no data) more frequently when checking the LibreLinkUp-App. Anyone exposed to a similar behaviour?

I do also get the <!DOCTYPE html> errors in heroku logs. Nightcout Uploads look like this:

2022-07-20T11:10:31.255389+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T11:15:00.707559+00:00 app[worker.1]: [info]: Upload of 1 measurements to NightScout succeeded 2022-07-20T11:20:31.004411+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T11:25:30.510628+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T11:30:00.979655+00:00 app[worker.1]: [info]: Upload of 1 measurements to NightScout succeeded 2022-07-20T11:35:30.491815+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T11:40:30.883211+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T11:45:01.402416+00:00 app[worker.1]: [info]: Upload of 1 measurements to NightScout succeeded 2022-07-20T11:50:30.752445+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T11:55:31.135782+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T12:00:00.613868+00:00 app[worker.1]: [info]: Upload of 1 measurements to NightScout succeeded 2022-07-20T12:05:30.885018+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T12:10:31.526429+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T12:15:00.855261+00:00 app[worker.1]: [info]: Upload of 1 measurements to NightScout succeeded 2022-07-20T12:50:31.173916+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T12:55:30.633494+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T13:00:01.083154+00:00 app[worker.1]: [info]: Upload of 1 measurements to NightScout succeeded 2022-07-20T13:05:30.411428+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T13:10:30.815833+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded 2022-07-20T13:15:00.464187+00:00 app[worker.1]: [info]: Upload of 1 measurements to NightScout succeeded 2022-07-20T13:20:31.476487+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded

LINK_UP_REGION is DE. Patient, follower, devices are all DE. Any help is appreciated.

Playing with values of LINK_UP_TIME_INTERVAL were not successful. Is there a way to get measurements by the minute again?

Best regards kaussel

timoschlueter commented 2 years ago

@kaussel i noticed that as well a few days ago but it has since gone back to normal (with 5 minutes intervals). I would assume that this was a server issue on Abbotts side. Can you check again if the problem still exists?

kaussel commented 2 years ago

@timoschlueter thanks for the info but I can't report any progress. the behaviour remains the same. I constantly miss 2 of 3 measurements. but I also think it's a problem on abbotts side,

since the linkup app often shows no data "---", I contacted their support and they claimed the issue may have been that I used the same email address for libreview and linkup. but using a new linkup account didn't change anything.

since I'm neither a programmer nor an avid log analysist maybe someone can light up the log entries for me. it essentially reports the Upload of 0 measurements every time the html error occurs. I assume there's nothing suspicious in the debug log entry? and the html error is a response to not being able to retreive anything from Abbott?

2022-07-30T10:55:00.372554+00:00 app[worker.1]: [debug]: authenticatedHttpHeaders: {"User-Agent":"FreeStyle LibreLink Up NightScout Uploader","Content-Type":"application/json","version":"4.2.2","product":"llu.ios","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Pragma":"no-cache","Cache-Control":"no-cache","authorization":"Bearer <_some_cryptic_identifier_>"} 2022-07-30T10:55:30.611665+00:00 app[worker.1]: [error]: "<!DOCTYPE html>\n\t\n\t \n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t<meta charset=\"utf-8\">\n\t\tApplication Error\n\t\t<style media=\"screen\">\n\t\t html,body,iframe {\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t }\n\t\t html,body {\n\t\t\theight: 100%;\n\t\t\toverflow: hidden;\n\t\t }\n\t\t iframe {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tborder: 0;\n\t\t }\n\t\t\n\t \n\t \n\t\t<iframe src=\"//www.herokucdn.com/error-pages/application-error.html\">\n\t \n\t" 2022-07-30T10:55:30.611816+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded

kaussel commented 2 years ago

just fyi: during last nights maintenance window by abbott I got normal uploads every 5 mins for about an hour, then falling back to the old error pattern again grafik

microspock commented 2 years ago

Great news !

Le jeu. 16 juin 2022 à 17:43, fabricejoubert @.***> a écrit :

Bonjour,

Pour information cette fonctionnalité vient d'être implémentée dans la dernière version xdrip et ça fonctionne très bien. Xdrip récupère directement les données libreview.

https://xdrip.readthedocs.io/en/latest/install/webfollower/

— Reply to this email directly, view it on GitHub https://github.com/timoschlueter/nightscout-librelink-up/issues/28#issuecomment-1157814411, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYC56TV42QHR6OHR6AXYIQDVPNDS3ANCNFSM5P4TOVHQ . You are receiving this because you commented.Message ID: @.***>