adamlonsdale / pylivoltek

0 stars 0 forks source link

Invalid token #1

Open d-solis-tovar opened 1 week ago

d-solis-tovar commented 1 week ago

Hi Adam,

I recently bought a Livoltek inverter and I'm trying to communicate with it via Livoltek API. The steps I'm following are:

  1. Get token with securid and key
  2. Include this token in headers: headers = {"Authorization": token}
  3. Include previously-generated userToken in parameters: params = {"userToken": userToken}
  4. Request the corresponding endpoint

After that, I got {'code': '500', 'message': 'token.invalid'}

However, when I make a request to hess/api/powerStationStatistics endpoint where no userToken is required, I get a valid response.

When generating userToken, effective date is set to "now time".

I'm quite stack on this and I can't find a solution. Hopefully you experienced some of these problems in the past.

Thank you in advance!

adamlonsdale commented 1 week ago

Hey @d-solis-tovar! Thanks for the info.

Out of interest are you inside the EMEA area? I'm based in the UK so I have to use the EMEA endpoint to connect to the API. I'm writing an integration to Home Assistant for Livoltek and I have some example of using the API in the helper.py file within that project.

In async_get_api_client I set the relevant host and login. The async_get_cur_power_flow method then shows an example of using that to get the current power flow from the API.

Let me know if you need anything else and I'd be happy to take a look!