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

LibreLink error 4 #172

Open
ScottyTM opened this issue Sep 28, 2024 · 10 comments · May be fixed by #184
Open

LibreLink error 4 #172

ScottyTM opened this issue Sep 28, 2024 · 10 comments · May be fixed by #184
Labels
enhancement New feature or request

Comments

@ScottyTM
Copy link

I'm using Librelink and had some issues in the past couple of days with the data sync.

I found this in the logs:
09-27 23:08:21.024 30338 5065 I GDH.Task.Source.LibreLinkTask: Send request to https://api.libreview.io/llu/auth/login
09-27 23:08:21.439 30338 5065 W GDH.Task.Source.DataSourceTask: Set state for source LIBRELINK: ERROR - Error (4)

A comment on a gist about the LibreLinkUp API pointed me in the right direction.

Apparently the Terms of Use have been updated. I had to log out of the LibreLinkUp App and log back in. Then I had to accept the new terms.

It's been working since then.

Maybe this can be outmated somehow.

@pachi81
Copy link
Owner

pachi81 commented Sep 28, 2024

Hi,
thank you for posting the solution! I already know this problem from some facebook threads. There are several solutions provided, so I wasn't really sure, what is the correct one.

Unfortunately there is a GDH user, which accepted the terms of use, but the error occurs again after some hours.
Maybe it is related to error 429 (Too many requests), as he also using LibreLinkUp App in parallel.

We will see.

Best regards,

Michael

@pachi81 pachi81 added the documentation Improvements or additions to documentation label Oct 9, 2024
@fpalab
Copy link

fpalab commented Oct 25, 2024

Hello. Installed yesterday and was greeted by the error 4: solved by accepting the Tou.

This step can also be performed from an app or a web service by calling the libreview.io api.
When the the login call returns a status 4, it also adds to the reply something like:
"step": { "type": "tou", "componentName": "AcceptDocument", "props": { "reaccept": true, "titleKey": "Common.termsOfUse", "type": "tou" } },
basically asking to reaccept the Tou.

Calling the service https://api.libreview.io/auth/continue/tou will fix that (returned status is 0). Just use the token returned by the half-failed login in the Bearer header.

You can find more details at this site https://libreview-unofficial.stoplight.io/, in case you don't already know it.

Anyway your app solved my issue to get the glucose on the car screen, as all of my Tasker customizations were basically neutralized by android auto.
Thanks!
Francesco

@pachi81
Copy link
Owner

pachi81 commented Oct 25, 2024

Hi @fpalab,
thank you very much for this information!!!
I know this docu, but accept the terms is new for me.
My problem is, I do not really know, how can I test it. I never had to accept the terms.
Do you have any example response from login, which contains the "step" for tou?

Thank you!

Regards, Michael

@fpalab
Copy link

fpalab commented Oct 25, 2024

I went through my notes and I could find this full reply to user/pass login request:

{
  "status": 4,
  "data": {
    "step": {
      "type": "tou",
      "componentName": "AcceptDocument",
      "props": {
        "reaccept": true,
        "titleKey": "Common.termsOfUse",
        "type": "tou"
      }
    },
    "user": {
      "accountType": "pat",
      "country": "CH",
      "uiLanguage": "en-US"
    },
    "authTicket": {
      "token": "the token here",
      "expires": 1719337966,
      "duration": 3600000
    }
  }
}

This is a reply for a registered account that needs to (re)accept the tou. This should happen whenever new Terms of Use are reissued, but it only shows when doing a user/pass login. That's why it's so difficult to test it.

The key here is data.step.type: its value defines the page to call for acceptance. In this case it is "tou" and thus refers to the url https://api.libreview.io/auth/continue/tou

In another case it was "pp" (I think it was for token renewal) and the url becomes
https://api.libreview.io/auth/continue/pp. I can't find the original info for this though.

In both cases reusing the provided token is mandatory. I assume the old one is invalidated.
I hope it helps you.

@pachi81
Copy link
Owner

pachi81 commented Oct 25, 2024

@fpalab thank you very much!!!
At the moment, I´m still testing the next version, so I will add this in the version after.
Regards, Michael

@pachi81 pachi81 added enhancement New feature or request and removed documentation Improvements or additions to documentation labels Oct 25, 2024
@pachi81
Copy link
Owner

pachi81 commented Nov 7, 2024

@fpalab Just one more question. Do you also know, if there is an API endpoint to accept the mail invitation?

@fpalab
Copy link

fpalab commented Nov 7, 2024

@pachi81 I have no idea, I never found something about that.

However, something can be inferred from the process.
The registration to Libre LinkUp requires getting an email for confirmation: I doubt there's an alternative Api. Although it's always possible to read the email and fetch the link (quite complex and invasive).

An alternative for those who just wish to read their own glucose on your app, is to use the same account as the LibreLink, and yes it works. Just register yourself for listening on LibreLink and then log in with the Api.
The drawback back here is the the user gives the main password to a third party app, which is not a secure practice.

Hope it helped a bit.

@pachi81
Copy link
Owner

pachi81 commented Nov 7, 2024

@fpalab thank you for your information.
I already use it with Librelinkup, but only for testing.
So I hoped, there is also a solution for the invitation, because some user does not understand it and also some users are thinking, that they need the LibreLinkUp app for my app, not only for setting up the user.

But if I can offer the tou, this will help.

Thank you for your information.

@pachi81
Copy link
Owner

pachi81 commented Nov 15, 2024

@fpalab: Very important! Abbott changed their interface.
You need to use a new min version, but it seems, that you also need more header-data.
Do you know anything about???

@pachi81
Copy link
Owner

pachi81 commented Nov 23, 2024

@fpalab: one more question to accept tou.
Do I need to set anything special? I´m using the token from the message, but get an error in response:
Code 401 received with message Unauthorized {"message":"MissingCachedUser"}

Thank you!

pachi81 added a commit that referenced this issue Nov 24, 2024
@pachi81 pachi81 linked a pull request Dec 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants