nightscout / AndroidAPS

Opensource automated insulin delivery system (closed loop)
https://wiki.aaps.app
GNU Affero General Public License v3.0
725 stars 1.76k forks source link

problem connecting to nightscout on AAPS 3.2.0.4 #3396

Closed aemad37 closed 3 months ago

aemad37 commented 3 months ago

Connecting to nightscout 15.0.2 ( hosted inside Homeassistant - as docker img) seems to give me and error message "401 - Missing or bad access token or JWT" the same server and token seem to connect fine if I use NSClient 3.1.0.3? not sure what gone wrong here


AAPSClient 3.2.0.4 NSCLIENT Build: 5d3e33ce8a-2024.02.27 Remote: https://github.com/nightscout/AndroidAPS.git Flavor: aapsclientrelease Nightscout version: UNKNOWN

nightscout version 15.0.2 head

XX.XX.XX.XX - - [05/Aug/2024:15:25:49 +1000] "GET /api/v1/entries/sgv.json HTTP/1.1" 200 2 "-" "HomeAssistant/2024.7.4 aiohttp/3.9.5 Python/3.12" XX.XX.XX.XX - - [05/Aug/2024:15:25:54 +1000] "GET /api/v3/status HTTP/1.1" 401 61 "-" "okhttp/4.12.0" Missing or bad access token or JWT XX.XX.XX.XX - - [05/Aug/2024:15:25:54 +1000] "GET /api/v2/authorization/request/XXXX-XXXXXXXXXXXXXXX HTTP/1.1" 200 280 "-" "okhttp/4.12.0" XX.XX.XX.XX - - [05/Aug/2024:15:25:54 +1000] "GET /api/v3/status HTTP/1.1" 401 61 "-" "okhttp/4.12.0" Missing or bad access token or JWT XX.XX.XX.XX - - [05/Aug/2024:15:25:54 +1000] "GET /api/v3/status HTTP/1.1" 401 61 "-" "okhttp/4.12.0" Missing or bad access token or JWT XX.XX.XX.XX - - [05/Aug/2024:15:25:54 +1000] "GET /api/v2/authorization/request/XXXX-XXXXXXXXXXXXXXX HTTP/1.1" 304 0 "-" "okhttp/4.12.0" XX.XX.XX.XX - - [05/Aug/2024:15:25:54 +1000] "GET /api/v3/status HTTP/1.1" 401 61 "-" "okhttp/4.12.0" Missing or bad access token or JWT XX.XX.XX.XX - - [05/Aug/2024:15:25:55 +1000] "GET /api/v3/status HTTP/1.1" 401 61 "-" "okhttp/4.12.0" Missing or bad access token or JWT XX.XX.XX.XX - - [05/Aug/2024:15:25:55 +1000] "GET /api/v2/authorization/request/XXXX-XXXXXXXXXXXXXXX HTTP/1.1" 200 280 "-" "okhttp/4.12.0" XX.XX.XX.XX - - [05/Aug/2024:15:25:55 +1000] "GET /api/v3/status HTTP/1.1" 401 61 "-" "okhttp/4.12.0" Missing or bad access token or JWT XX.XX.XX.XX - - [05/Aug/2024:15:25:55 +1000] "GET /api/v3/status HTTP/1.1" 401 61 "-" "okhttp/4.12.0" Missing or bad access token or JWT XX.XX.XX.XX - - [05/Aug/2024:15:25:55 +1000] "GET /api/v2/authorization/request/XXXX-XXXXXXXXXXXXXXX HTTP/1.1" 304 0 "-" "okhttp/4.12.0" XX.XX.XX.XX - - [05/Aug/2024:15:25:55 +1000] "GET /api/v3/status HTTP/1.1" 401 61 "-" "okhttp/4.12.0" Missing or bad access token or JWT

olorinmaia commented 3 months ago

Hi :) Please read release notes, and especially: https://androidaps.readthedocs.io/en/latest/Installing-AndroidAPS/Releasenotes.html#important-comments-on-using-v3-versus-v1-api-for-nightscout-with-aaps

If you want to use NSclientV3 you need to create access tokens in Nightscout. This is done in NS admin tools. If you use NSClientv1 you can use API SECRET as used in 3.1.0.3.

If you want to use NS+ button and have correct basal showing in NS you need to use NSClientv1. V3 currently isn't able to due to a rendering bug in NS.

aemad37 commented 3 months ago

Sorry I commented through the wrong account earlier 😅

Thanks for replying man ... I just tried again everything fresh and yes you're right v1 works Not sure what was wrong before but yeah it does work now for the combination of 3.2.0.4 and ns15 Hopefully this might help someone else

Tho just for the record I was using tokens with v3 and it did authenticate then it threw the http 401 error I reckon it's not worth having this ticket now since you're saying v3 is kinda not ready? Should I close it ? Or leave it there ?

Cheers 🙏

olorinmaia commented 3 months ago

Make sure tokens generated have admin access.

In my opinion. If you are following a child you'd want websockets, v1 wins as it got no issues with NS atm. If you dont rely on NS or accurate basal rendering or got followers, v3 is probably best as you can turn off websockets to save power.

aemad37 commented 3 months ago

Yeah I see

It is my 2 yo yeah he recently got diagnosed with t1d and trying to get everything as monitored/automated as much as possible.. so it does make sense to stick to v1 as I don't really care about the power consumption and I'd rather have a more reliable and live link.

Thanks again man I've been scratching my head late at night for 2 days now lol 🙏❤️

olorinmaia commented 3 months ago

I use v1 to follow my 8yo son and based on alot of testing of both NSClient versions v1 is best. V3 will probably get better in future.

Good luck. You got the best system on your hands now 👍💙

aemad37 commented 3 months ago

Yup definitely like it Same to you man 🙏✌️