joelhi / glucose-viewer-pico

Project to view Freestyle Libre 2 glucose readings in real-time on a Raspberry Pico
MIT License
3 stars 0 forks source link

403 response #9

Open sum1els opened 4 months ago

sum1els commented 4 months ago

Hi, thanks for creating this !

I am getting a 403 response for the API call, with what looks like a cloudflare page about being blocked. If I do a curl with the same details from a linux host I get a proper response:

Running this from the pico: Logging in... Connecting to https://api.libreview.io/llu/auth/login Response code: 403 Response:

b'<!DOCTYPE html>\n\n\n\n \n\nAttention Required! | Cloudflare\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n

\n \n
\n
\n

Sorry, you have been blocked

\n

You are unable to access libreview.io

\n
\n\n
\n
\n
\n \n \n \n
\n
\n
\n\n
\n
\n
\n

Why have I been blocked?

\n\n

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

\n
\n\n
\n

What can I do to resolve this?

\n\n

You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.

\n
\n
\n
\n\n \n\n\n
\n
\n\n \n\n\n\n'

Traceback (most recent call last): File "", line 3, in File "adapters/libreview_adapter.py", line 33, in login ValueError: syntax error in JSON

Ever seen that before ?

Thanks

sum1els commented 4 months ago

when I run that same, using the requests module on my desktop, the API call works

joelhi commented 4 months ago

Hey!

Yes, I started getting this very recently, like the past week or so, which has caused some issues with the project. It had been running smoothly for the past 6 months before. Not sure if they recently added some additional security layer. 🤔 Unfortunately I haven't had the time to figure out what is going on yet.

Interesting that it seems to work in different environments. Looking to find the time to sit down and have a proper look at this, but let me know if you find anything else out in the meantime.

Sorry I couldn't be of more help.

Joel

sum1els commented 4 months ago

I have no idea why it's happening, not sure if the requests library in the newer micropython is messing the headers up or something, but using yours as an inspiration, I used circuitpy (adafruit requests library), with the waveshare 2" IPS screen (ST7789 library), which shows the colors very nicely at any angle.

25baa38a-164b-45fd-83e4-2e0ab98e7951

joelhi commented 4 months ago

Looks really nice!

Interesting, I'll give it a go. As you said, it sounds like there may be something in the urequests library that trigger cloudflare. Maybe it will catch up with circuitpy as well but let's see.

spordiab commented 3 months ago

sum1els

Oh great work @sum1els, would it be possible to have the code because I use the same hardware and Freestyle libre 2. I tried the ghitub code but unable to connect with Libreview API.

Thank you so much

sum1els commented 3 months ago

@spordiab sure, I have uploaded it here: https://github.com/sum1els/circuitpy-glucose-display

thanks to @joelhi for the inspiration, not sure what is wrong with the urequest library, but circuitpy worked for me, however, not sure if it runs out of memory, since sometimes after a few days. maybe weeks the display just goes blank and I need to restart it. Could be my bad programming ;)

spordiab commented 3 months ago

@spordiab sure, I have uploaded it here: https://github.com/sum1els/circuitpy-glucose-display

thanks to @joelhi for the inspiration, not sure what is wrong with the urequest library, but circuitpy worked for me, however, not sure if it runs out of memory, since sometimes after a few days. maybe weeks the display just goes blank and I need to restart it. Could be my bad programming ;)

Thank you for your response and your work.

I'll try to install it and get back to you.