tinytuya
tinytuya copied to clipboard
Error from Tuya server: permission deny
Hi, after inputing client id, secret etc i got error Error from Tuya server: permission deny
Is there any way to see what exactly go wrong? All services is added to device on the iot cloud web site.
I subscribed to trial version
Might be thats the problem - https://developer.tuya.com/en/docs/iot/singnature?id=Ka43a5mtx1gsc
Hi @skorphil we updated TinyTuya to handle the new signature requirement. Make sure you are using the latest version. Also, some report an issue with region selection in the Tuya portal - check this out: https://github.com/jasonacox/tinytuya/issues/59
Hi @jasonacox I have added all the servers in the project on tuya iot web site.
I have tried all different regions us, eu, cn, in in tinytuya wizard with no results.
Do i have to create assets(with user and devices) in different regions?
Well, i've tried different combinations of Asset Server location and Region on tinytuya wizard. Doesn't seem to work - access denied.
Do i need to run tinytuya wizard on machine in the same LAN with the device? I wanna try run it on remote vps from different region - maybe this will make any sense. I still wondering is there a way i can get additional information why access is denied? It might help to find a solution
I've tried different combinations of regions running wizard from europe VPS. Still have access denied. It need so much time to try every combination because there are 6 server options on tuya iot assets(where i have to manually add new device for each server) and i have 4 choices of regions in tinytuya wizard. So i've tried only some combinations. I do not understand the logic behind access to those regions.
Which development method should i use for tuya project? Custom or Smart Home?
Thats insane ))) this error makes me mad cause it describes nothing in terms of how can i fix it
Well, i've managed to get local key via API on the tuya web site as described here https://community.home-assistant.io/t/inkbird-ibs-m1-with-ibs-p01/255050/20?u=del13r
Test python code seems to work with my device
Hi @skorphil I understand your frustration. If you are still interested in troubleshooting this, I have some ideas.
Do i have to create assets(with user and devices) in different regions?
No, key is that you want to use the region where your tuya devices are registered. Which region do they show up in on the Tuya Developer (iot.tuya.com) portal? Here is what my account shows:

The TinyTuya wizard basically does a sequence of curl actions against the Tuya API to get the local key for all of your devices. You can simulate this in the Tuya iot portal:
Here is what we do to get the full list:
- Get the user id (uid) by using the sample device ID in your collection:

Notice the region that is selected. This will match the us, eu, cn, in that the wizard asks and will show up in the curl statement as the hostname (e.g. for the us, curl --request GET "https://openapi.tuyaus.com/v1.0/devices...)
- Using the user id (uid), ask for a full list of all devices:

I've been running into this issue with tinytuya and directly with the API for a couple hours and the only way that I could resolve it was by moving the app and devices from the East US region to the Western US region.
That's a great find @dlapiduz ! I see Tuya now has these regions:
| Region | Endpoint |
|---|---|
| China Data Center | https://openapi.tuyacn.com |
| Western America Data Center | https://openapi.tuyaus.com |
| Eastern America Data Center | https://openapi-ueaz.tuyaus.com |
| Central Europe Data Center | https://openapi.tuyaeu.com |
| Western Europe Data Center | https://openapi-weaz.tuyaeu.com |
| India Data Center | https://openapi.tuyain.com |
From: https://developer.tuya.com/en/docs/iot/api-request?id=Ka4a8uuo1j4t4
Currently it only handles this format:
url = "https://openapi.tuya%s.com/v1.0/%s" % (apiRegion,uri)
I will update TinyTuya to handle the new ones:
| Region | Endpoint |
|---|---|
| Eastern America Data Center | https://openapi-ueaz.tuyaus.com |
| Western Europe Data Center | https://openapi-weaz.tuyaeu.com |
Hello, I'm running into the same problem. this is the response I get:
{ "code": 1106, "msg": "permission deny", "success": false, "t": 1644162150193 }
That means that your datacenter region settings are not correct for your local IP address. Unfortunately, Tuya's regions don't really map correctly to physical regions. Tuya is aggressive about regions. If you call from an IP that looks like it is outside of the region they expect, it will be denied. I would try adding other data centre regions in the Tuya cloud portal to your project and try using those regions in the Wizard.
Take a look at the advice in these issues and see if it helps you: https://github.com/jasonacox/tinytuya/issues/100 https://github.com/jasonacox/tinytuya/issues/96
I just used the root android method to get my key, way easier.... After than everything went smoothly
Excellent! Did you find a good tutorial on that? I would be happy to add that link.
- Get smartlife 3.3.0 apk, install it on a rooted android phone.
- Log in, then pair your devices, make sure to rename your devices after pairing.
- Go to /data/data/com.tuya.smartlife/shared_prefs using any root explorer application.
- there will be a file called preferences_global_xxxxxxxx.xml where xxxxxxxx is a random number.
- Search for “local” with any text editor in that file, if found scroll to the right and you will see a 16 digit number, that's your local key.
Basically preferences_global_xxxxxxxx.xml is kind of a log file, and it just happens that in this particular app version the file is totally unencrypted and it also shows the local key used for pairing. No need to do any tuya developer stuff.
Original post: https://sites.google.com/view/randyhomeassistant/tuya-local.
Thanks @axydavid - great find! Hopefully this will help others. I assume if you have multiple Tuya devices it will likely be multiple "local" items in that folder that will have their keys.
Not that you need it but if any follow after you without an Android device or just wanting to the the Tuya Cloud to work for them, I created a PDF that might help: Tuya.IoT.API.Setup.pdf
I assume if you have multiple Tuya devices it will likely be multiple "local" items in that folder that will have their keys.
Precisely!!! The data is stored in JSON format.
Not that you need it but if any follow after you without an Android device or just wanting to the the Tuya Cloud to work for them, I created a PDF that might help: Tuya.IoT.API.Setup.pdf Might come in handy.
I just want to add that you can actually boot an android live cd on your PC in case you don't own an android phone.
I love this idea @axydavid . I would love to have a push-button easy way for users to get their local keys without the Tuya IoT dev path. Would it be possible for us to build an automated script (container) to set up a android emulator on your PC, execute the installation and login of the SmartLife app and then grab the JSON data for the local keys?
In theory, you could modify the 3.3.0 smarthome app so that it copies or displays the local key once the device is paired. That way you wouldn't need root anymore in order to access it. This would be the most realistic approach IMHO.
Another detail worth mentioning is that you could also remove any tracking from the app as well, the app already uses the local control of the devices.
For the PC idea, it would be complicated, since if you run emulated android would the app still be able to see the device since the wifi connection is not direct, but relayed? So the only realistic way would be to have a sort of android liveCD, however I think it's much easier and faster just to use any old android phone.