SAIC-iSmart-API / saic-python-client

MIT License
12 stars 5 forks source link

saic_ismart_client tells me "incorrect password" #15

Open elmer0815 opened 11 months ago

elmer0815 commented 11 months ago

I have a problem with the saic_ismart_client telling me I used a wrong pasword. But I'm sure I use the correct one...

I'm able to login to the ismart app with the same PW and userid I tried to use for the saic-python-mqtt-gateway. The app login works fine - after I reconnect in the app saic resets my failed logons to 5 attempts.

When I try to login through the gateway it doesn't work. Is there a restriction in the pw length? I looked at your code and think that there should be no problem with my pw. The password has 20 characters, upper/ lowercase and numbers - no special characters. As I see in the code a password between 6 and 30 characters is supported...

But now I don't have any idea what could be wrong...

My environment: Everything runs in Docker. I use the saic-python-mqtt-gateway from docker hub. I also have a mosquitto and evcc running in docker. According to the logs the connections between evcc <--> mosquitto <--> saic-python-mqtt-gateway seems to work.

Just the connection saic-python-mqtt-gateway <--> saic api seems to fail :-(

Status: Downloaded newer image for saicismartapi/saic-python-mqtt-gateway:latest
2023-11-26 11:23:30,399 [  INFO  ] Connected to MQTT broker - mqtt_publisher
2023-11-26 11:23:30,402 [  INFO  ] Scheduler started - apscheduler.scheduler
2023-11-26 11:23:31,268 [ ERROR  ] MqttGateway crashed due to SaicApiException - __main__
Traceback (most recent call last):
  File "/usr/src/app/./mqtt_gateway.py", line 301, in run
    login_response_message = self.saic_api.login()
  File "/usr/local/lib/python3.10/site-packages/saic_ismart_client/saic_api.py", line 122, in login
    raise SaicApiException(login_response_message.body.error_message,
saic_ismart_client.exceptions.SaicApiException: return code: 15019, message: Incorrect password. You may have another 3 attempts of the day,please try again.
return code: 15019, message: Incorrect password. You may have another 3 attempts of the day,please try again.

regards elmer

tosate commented 11 months ago

Does your password contain an ampersand?

elmer0815 commented 11 months ago

No - just normal characters (upper/lowercase) and numbers... The length of the pw is 20 characters.

Update: and also no special character like äöüß

tosate commented 11 months ago

Is there maybe a white space behind your password in your variable definition?

elmer0815 commented 11 months ago

I start the gateway via docker:

sudo docker run --label=com.centurylinklabs.watchtower.enable=true --restart=no --name saic-python-mqtt-gateway -e SAIC_USER=saicaccemail@provider.net -e SAIC_PASSWORD=ThisIsmySecurePW123 -e MQTT_URI=tcp://172.17.0.4:1883 -e MQTT_USER=saicmg4 -e MQTT_PASSWORD=myMQttPW456 saicismartapi/saic-python-mqtt-gateway:latest

There is no whitespace after the pw...

After I started this, it ends with the error message mentioned earlier (wrong pw). In portainer I can see the environment variables I passed to this container and the SAIC_PASSWORD is absolutely correct... I did a copy/paste and checked with the original PW.

Update:
I thought it could be a problem with the LANG or LC_ALL variable and played with C.UTF-8, en_US.UTF-8 and de_DE.UTF-8. But also without success... :-(

lcanod commented 2 months ago

Same issue here, same password error even tough I'm 100% sure it's correct. I can login in the APP, but not through the Add-on.

Tried with the Phone number as user and also with the mail. No sucess.

Password with no strange characters, only numbers and letters to simplify, but it doesn't work

Were anyone able to troubleshoot or identify the issue?

tosate commented 2 months ago

Hi @lcanod

if you are using the latest version of the MQTT Gateway, then the login and all the other API requests are handled by saic-python-client-ng

In this case you can find on your MQTT broker the topic saic/_internal/api/oauth/token/request that shows you the actual login request that has been sent to the SAIC API. The body starts with grant_type=password&username=<your-user>&password=<your-hashed-password>.

Not the password is sent to the SAIC API, but its SHA1 hash value. You can validate this value in Bash:

echo -n "your-password" | sha1sum

I hope that you can debug the issue with this information.

lcanod commented 2 months ago

My bad, tosate. I was wrongly thinking in the SAIC_MQTT Gateway, and due to the frustration and browsing a lot to try to find out a solution, I didn't realize this is the phyton client instead. :-(

Sorry about that. I still have the login issue, but not with the saic-python-client, but with the saic-python-mqtt-gateway

Any help related to the MQTT Gateway is appreciated anyway ;-)

Sorry about that