TuyaAPI / openapi

🚪 a wrapper for Tuya's OpenAPI
https://github.com/TuyaAPI/openapi/blob/master/docs/classes/api.openapi.md
MIT License
20 stars 13 forks source link

I need help #9

Open HaydenRichardson opened 3 years ago

HaydenRichardson commented 3 years ago

Can someone help me with the setup.

codetheweb commented 3 years ago

Please include more details about where you're getting stuck.

HaydenRichardson commented 3 years ago

@codetheweb ok so const OpenAPI = require('@tuyapi/openapi');

const api = new OpenAPI({key: '10101010', secret: '1010101010', schema: '10101010'});

(async () => { // Must be called before any other operations to get auth token await api.getToken();

const uid = await api.putUser({ countryCode: '1', username: 'my-username', password: 'c7fb2740c5fc45660d9e4ed765a479fa', usernameType: 1});

console.log(uid);

const token = await api.getDeviceToken({uid, timezone: 'America/Chicago'});

console.log(token);

console.log(await api.getDevicesByToken('EkjQjlbo')); })(); i have all of this and i get this error UnhandledPromiseRejectionWarning: Error: sign invalid at OpenAPI._client.got_1.default.extend.hooks.afterResponse (/root/ping-pong-bot/my-bot/node_modules/@tuyapi/openapi/dist/api.js:74:31) also i was wondering if you had a discord?

HaydenRichardson commented 3 years ago

actually this is my code const OpenAPI = require('@tuyapi/openapi'); const api = new OpenAPI({key: '*', secret: '*****', schema: 'sjmnsjdkag09kd08zf9m'});

(async () => { // Must be called before any other operations to get auth token await api.getToken();

const uid = await api.putUser({ countryCode: '1', username: 'hayden.richardson625@yahoo.com', password: '*****', usernameType: 1});

console.log(uid);

const token = await api.getDeviceToken({uid, timezone: 'America/New-York'});

console.log(token);

console.log(await api.getDevicesByToken('EkjQjlbo')); })();

codetheweb commented 3 years ago

If you're getting sign invalid either your key or secret is probably wrong. Please double-check those values.

HaydenRichardson commented 3 years ago

is that how i would do the timezone?

HaydenRichardson commented 3 years ago

@codetheweb Do i put the devices id or the projects id for schema?

HaydenRichardson commented 3 years ago

I need to start asking these questions in one comment but for username and password i use the email and password for https://iot.tuya.com/.

HaydenRichardson commented 3 years ago

@codetheweb i think i fixed that error but now its telling me permission denied.

codetheweb commented 3 years ago

You should use the user account you sign into the app with for credentials here instead of the credentials used to sign into iot.tuya.com.

HaydenRichardson commented 3 years ago

o ok