smarthomej / addons

SmartHome/J addons for openHAB
Eclipse Public License 2.0
61 stars 25 forks source link

Tuya Binding: Unable to Authenticate #281

Closed rdiem closed 2 years ago

rdiem commented 2 years ago

I installed the Binding in openhab 3.2 and created a project thing. It stays oflline and shows COMMUNICATION_ERROR

The code of the thing is: UID: tuya:project:4909c45920 label: Tuya Cloud Project thingTypeUID: tuya:project configuration: accessId: MY_ACCESS_ID schema: smartLife password: MY_APP_PASSWORD dataCenter: https://openapi-weaz.tuyaeu.com countryCode: 49 accessSecret: MY_ACCESS_SECRET username: my.appusername@googlemail.com

The TRACE log shows:

22:40:13.524 [TRACE] [nding.tuya.internal.cloud.TuyaOpenAPI] - Sending to 'https://openapi-weaz.tuyaeu.com/v1.0/iot-01/associated-users/actions/authorized-login': Method = {POST}, Headers = {Accept-Encoding: gzip, User-Agent: Jetty/9.4.43.v20210629, sign_method: HMAC-SHA256, access_token: , sign: THESIGN, client_id: MY_ACCESS_ID, t: 1641159613523, Signature-Headers: client_id, Content-Type: application/json}, Content = {{"username":"my.appusername@googlemail.com","password":"ENCODED_PASSWORD","country_code":49,"schema":"smartLife"}}

22:40:13.621 [TRACE] [ya.internal.cloud.TuyaContentListener] - Received from 'https://openapi-weaz.tuyaeu.com/v1.0/iot-01/associated-users/actions/authorized-login': Code = {200}, Headers = {Content-Type: application/json;charset=UTF-8, Content-Length: 89, Connection: keep-alive, Date: Sun, 02 Jan 2022 21:40:13 GMT, Access-Control-Allow-Credentials: true, Access-Control-Allow-Headers: , Access-Control-Allow-Headers: access_token,Content-Type, Access-Control-Allow-Methods: POST, Access-Control-Allow-Methods: OPTIONS, Access-Control-Allow-Methods: GET, Access-Control-Allow-Methods: DELETE, Access-Control-Allow-Methods: PUT, Access-Control-Allow-Origin: https://iot.tuya.com, Gateway-Info: highway, Strict-Transport-Security: max-age=31536000;includeSubDomains;preload}, Content = {{"code":1109,"msg":"param is illegal ,please check it","success":false,"t":1641159613600}}

Found this: https://support.tuya.com/en/help/_detail/K9g77zprbu5u6
Please check if the url parameter grant_type=1 is missing

J-N-K commented 2 years ago

Are you sure you selected the correct datacenter? The standard for Germany is Central Europe. And which App are you using? The blue or the orange one?

rdiem commented 2 years ago

You're right. It was the wrong datacenter. I use the smartlife app - so the blue one. When linking the Link Tuya App Account with the wrong datacenter there are 0 devices in table shown. So thats a good indicator if choosing the correct datacenter.

@J-N-K Thanks for your hint! Now it is working.

J-N-K commented 2 years ago

Good point. I'll add that to the docs. Thanks.