timoschlueter / nightscout-librelink-up

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

Uploading values to nigtscoutpro fails #96

Closed ConstantinSchreiber closed 1 year ago

ConstantinSchreiber commented 1 year ago

Hi @timoschlueter,

first off thanks a lot for open sourcing your sync script! This really seems to be the only viable option out there to get the Libre 3 values synched to Nightscout - really appreciate it.

I've deployed the script on heroku and pulling the values from librelink seems to work but I'm getting an auth error trying to upload to nightscout.

I'm running a hosted nightscout instance on nightscoutpro.com. I've already double checked the credentials and tried disabling HTTPS.

This is the debug log output:

2023-06-06T18:25:00.226203+00:00 app[worker.1]: [info]: renew token 2023-06-06T18:25:00.590834+00:00 app[worker.1]: [info]: Logged in to LibreLink Up 2023-06-06T18:25:00.591059+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":"REDACTED"} 2023-06-06T18:25:00.697273+00:00 app[worker.1]: [info]: Found 1 LibreLink Up connection. 2023-06-06T18:25:00.697483+00:00 app[worker.1]: [info]: -> The following connection will be used: Constantin Schreiber (Patient-ID: 75f90586-03a0-11ee-a4fb-0aeb61c9dc79) 2023-06-06T18:25:00.697548+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 REDACTED"} 2023-06-06T18:25:00.936048+00:00 app[worker.1]: [error]: {"status":401,"message":"Unauthorized","description":"Invalid/Missing"} 2023-06-06T18:25:00.937174+00:00 app[worker.1]: [info]: Trying to upload 140 glucose measurement items to Nightscout 2023-06-06T18:25:01.027178+00:00 app[worker.1]: [error]: {"status":401,"message":"Unauthorized","description":"Invalid/Missing"} 2023-06-06T18:25:01.027455+00:00 app[worker.1]: [error]: Upload to NightScout failed

Any ideas?

timoschlueter commented 1 year ago

Hi @ConstantinSchreiber lets find out what's causing this:

How did you generate the API Token for Nightscout? A lot of users had issues with using the Admin-Token instead of a newly created Nightscout Token for a "subject". Have you created a new subject within Nightscouts Admin Tools and used the generated token in the environment variable?

Could you maybe share your set environment variables? With privacy relevant information redacted of course! :)

ConstantinSchreiber commented 1 year ago

@timoschlueter you're a legend!

The issue was exactly what you've outlined. After creating a new subject and using the accompanying token everything works like a charm now. Thanks a lot!

timoschlueter commented 1 year ago

awesome! Glad I could help :)