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

Auto-detect Region #421

Open
CrazyMarvin opened this issue Jan 6, 2025 · 9 comments
Open

Auto-detect Region #421

CrazyMarvin opened this issue Jan 6, 2025 · 9 comments
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed

Comments

@CrazyMarvin
Copy link
Contributor

At the moment the user needs to select the correct endpoint manually.
Do you have an idea how to automate it, @KiSa04?

@CrazyMarvin CrazyMarvin added enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed labels Jan 6, 2025
@KiSa04
Copy link

KiSa04 commented Jan 6, 2025

Actually, they disabled their region-based restrictions a few days ago.
You can remove everything that has to do with region -- calling "https://api.libreview.io/llu" now redirects to the correct one

So, in this file, you should use your 'BASE_URL' instead of 'getBaseUrl', that function is useless now.

But the reason why your app is crashing isn't this: it crashes when it reaches the "connections" API. you need to grab this value during login:

{ "data" : { "user" : { "id" : "xxxxxxx-xxx-xxxx-xxx-xxxxx"

encode it with sha256 and pass it as a header when calling 'https://api.libreview.io/llu/connections'

Example:
Account-Id: 0728de934781f1d5a1a775df21ce6e0aa6b7192e43b9a19b4ccef5bt2c528921

@KiSa04
Copy link

KiSa04 commented Jan 7, 2025

Just to let you know that for germany, the region is still active, so you need to add a fallback.

if the login (using https://api.libreview.io/llu) returns a "region" value ( {"status":0,"data":{"redirect":true,"region":"de"}}), then you need to login again with "https://api-"+ data.region + "libreview.io/llu"

this is how my fallback code looks like (using C#):

if (JsonLogin.data.region != null) { region = $"-{JsonLogin.data.region}"; loginUrl = $"https://api{region}.libreview.io/llu/auth/login";

@CrazyMarvin
Copy link
Contributor Author

Thanks for the information. 👍
I will keep the regions for now but may remove them later.

@drmzk
Copy link

drmzk commented Feb 17, 2025

Hi, and massive thanks for what seems to be a great project!

I'm in South Africa, and of course my region is not listed. Is there a workaround that you might suggest?

I don't even know what the regions are there for. I'm a programmer and I'd like to try this desktop application, but I'd also like to perhaps fork from DiaKEM to make something like a SugarPixel, but open sourced and easy to put together. My very young child is T1 and it would be an incredible asset to all those that care for him if there were a better early warning and notification system. In turn, ours is a poor country and most parents of T1 kids are far below the economic line to afford a SugarPixel - something that helps parents in general would be just wonderful.

Many thanks!

@CrazyMarvin
Copy link
Contributor Author

Hi, and massive thanks for what seems to be a great project!

Thanks for your kind words.

I'm in South Africa, and of course my region is not listed. Is there a workaround that you might suggest?

I suppose that South Africa does not have an own endpoint.
We might add a new global endpoint which should cover South Africa. 🤔

I don't even know what the regions are there for. I'm a programmer and I'd like to try this desktop application, but I'd also like to perhaps fork from DiaKEM to make something like a SugarPixel, but open sourced and easy to put together. My very young child is T1 and it would be an incredible asset to all those that care for him if there were a better early warning and notification system. In turn, ours is a poor country and most parents of T1 kids are far below the economic line to afford a SugarPixel - something that helps parents in general would be just wonderful.

Since I am not using the official Libre 3 Android app anymore because I moved from ICT to CSII with CamAPS I got an Nightscout instance and tried the Nightscout Clock.

Many thanks!

You're welcome!

@CrazyMarvin
Copy link
Contributor Author

What do you think about creating a new endpoint Global that directly calls https://api.libreview.io/llu, @KiSa04 & @fperera123?

@drmzk
Copy link

drmzk commented Feb 17, 2025

Wow, @CrazyMarvin - hats off for the quickest github response I've ever seen!

Thanks - a global endpoint would be appreciated for sure. It's not just us; Libre 2 is in wide use around the world and not covered by the endpoint list.

In fact (and rather cynically), I think Libre 2 is being peddled widely in the 3rd world because it has been deprecated by the Libre 3. Many of us believe that Abbott is trying to ditch stock while it still has some use, although their support for it is not great because their attention is on the Libre 3 userbase.


I have checked out the Nightscout Clock #wicked and I loved it! However, the setup for Nightscout is extremely technical and most Average Parents just can't get all of that organized, even though the benefits are terrific. I'm keen to make a clock that just scours the data like a LibreLinkup follower - no server instance, no fiddling. Well, that's the dream.

Cheers!

@CrazyMarvin
Copy link
Contributor Author

Wow, @CrazyMarvin - hats off for the quickest github response I've ever seen!

Thanks - a global endpoint would be appreciated for sure. It's not just us; Libre 2 is in wide use around the world and not covered by the endpoint list.

Can you test if the global endpoint https://api.libreview.io/llu works for you?

In fact (and rather cynically), I think Libre 2 is being peddled widely in the 3rd world because it has been deprecated by the Libre 3. Many of us believe that Abbott is trying to ditch stock while it still has some use, although their support for it is not great because their attention is on the Libre 3 userbase.

The endpoints should work for Libre 2 and 3 in the same way.

I have checked out the Nightscout Clock #wicked and I loved it! However, the setup for Nightscout is extremely technical and most Average Parents just can't get all of that organized, even though the benefits are terrific. I'm keen to make a clock that just scours the data like a LibreLinkup follower - no server instance, no fiddling. Well, that's the dream.

Cheers!

Let us know when your clock is ready. 🥳

@KiSa04
Copy link

KiSa04 commented Feb 17, 2025

What do you think about creating a new endpoint Global that directly calls https://api.libreview.io/llu, @KiSa04 & @fperera123?

As i explained before, that should be the standard call! the login call at the global API (https://api.libreview.io/llu) returns one of three results:

  1. Failed Login
  2. data response structure (it's the case for South Africa)
  3. region redirect on a JSON structure (e.g. "region": "eu")

you should check which does it return. If it returns a region, then you need to call "https://api-{region}.libreview.io/llu" and proceed as usual.

that avoids asking the user for its region

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants