Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

403 response #9

Open
sum1els opened this issue May 13, 2024 · 7 comments
Open

403 response #9

sum1els opened this issue May 13, 2024 · 7 comments

Comments

@sum1els
Copy link

sum1els commented May 13, 2024

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'\n\n\n\n \n\n<title>Attention Required! | Cloudflare</title>\n\n\n\n\n\n\n\n<style>body{margin:0;padding:0}</style>\n\n\n\n<script>\n if (!navigator.cookieEnabled) {\n window.addEventListener('DOMContentLoaded', function () {\n var cookieEl = document.getElementById('cookie-alert');\n cookieEl.style.display = 'block';\n })\n }\n</script>\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 Cloudflare Ray ID: 8835eb638ed8e1d7\n \n \n Your IP:\n Click to reveal\n X.X.X.X\n \n \n Performance & security by Cloudflare\n \n

\n <script>(function(){function d(){var b=a.getElementById("cf-footer-item-ip"),c=a.getElementById("cf-footer-ip-reveal");b&&"classList"in b&&(b.classList.remove("hidden"),c.addEventListener("click",function(){c.classList.add("hidden");a.getElementById("cf-footer-ip").classList.remove("hidden")}))}var a=document;document.addEventListener&&a.addEventListener("DOMContentLoaded",d)})();</script>\n
\n\n\n
\n
\n\n <script>\n window._cf_translation = {};\n \n \n</script>\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
Copy link
Author

sum1els commented May 13, 2024

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

@joelhi
Copy link
Owner

joelhi commented May 14, 2024

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
Copy link
Author

sum1els commented May 22, 2024

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
Copy link
Owner

joelhi commented May 22, 2024

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
Copy link

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
Copy link
Author

sum1els commented Jun 13, 2024

@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
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants