PTST / LibreView-HomeAssistant

Integrate your LibreLink sensor data with Home Assistant
4 stars 0 forks source link

Login not possible #23

Closed selbstmacher closed 1 month ago

selbstmacher commented 2 months ago

It always says that it can not log in. But I verified that the password is correct. I think it is because of the 2-factor authentification. Is there a way around this?

PTST commented 2 months ago

@selbstmacher Are you able to login to the LinreLinkUp app with those credentials? I haven't even seen a 2fa setting in that app.

But one possible solution is to just not use the same account that you use with your librelink app. So just invite another email that you have and use that new account to login to the integration

GrmpfNarf commented 1 month ago

Hi, I have the same issue. I used another E-Mail and created a new account in LibreLinkUp. But unfortunately this didn't helped.

GrmpfNarf commented 1 month ago

Hi, the logs are not very helpful for me it just says: DEBUG (MainThread) [custom_components.libreview] Could not log in to LibreView, 'authTicket'

GrmpfNarf commented 1 month ago

Hi, I have found the reason for this issue. When I send a Authenticationrequest to https://api.libreview.io/llu/auth/login I get the following response:

{
    "status": 0,
    "data": {
        "redirect": true,
        "region": "de"
    }
}

So the API tells me to use the Server for my region "de". I changed the URL to https://api-de.libreview.io/llu/auth/login and I get the correct response.

Workaround to fix this in homeassistant: LibreView-Homeassistant uses LibreView as dependency/requirement. The URL is located in LibreView not in LibreView-Homeassistant.

  1. Find out where LibreView is located.
    1. Access your Homeassistant Installation Bash (for docker e.g. docker exec -it CONTAINER_ID bash)
    2. Execute: pip list -v
    3. Search for LibreView in output and copy the directory
  2. Got to PATH/TO/LibreView/utils
  3. Edit line 23 in API.py
    base_url = "https://api.libreview.io

    to

    base_url = "https://api-YOUR-REGION.libreview.io
  4. Save
  5. Restart Homeassistant
PTST commented 1 month ago

@GrmpfNarf that is perfect! 🙂 I don't know why my own credentials just works on the api.libreview endpoint without a region then, i just assumed that the regional servers were backups/cdns and everbody could use the main server.

I have updated the underlying API package to support regions, and which will automatically follow the redirect returned from the API
I have also published a new version of the home assistant integration that allows you to select the region manually, but it should just start following the redirect from now on.

GrmpfNarf commented 1 month ago

Hi, I can confirm that this works for me now without my workaround. What I have tested:

  1. Just update -> Worked
  2. Uninstall via Devices & Services (not HACS) and reinstall -> Does not work (Authentication Error)
  3. Uninstall via HACS and reinstall -> Worked

Maybe number 2 has something to do with my workaround or maybe I should have restarted before the reinstall.