openapi icon indicating copy to clipboard operation
openapi copied to clipboard

I need help

Open HaydenRichardson opened this issue 4 years ago • 10 comments

Can someone help me with the setup.

HaydenRichardson avatar Mar 29 '21 18:03 HaydenRichardson

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

codetheweb avatar Mar 29 '21 19:03 codetheweb

@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 avatar Mar 29 '21 20:03 HaydenRichardson

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: '[email protected]', 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')); })();

HaydenRichardson avatar Mar 29 '21 20:03 HaydenRichardson

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

codetheweb avatar Mar 29 '21 21:03 codetheweb

is that how i would do the timezone?

HaydenRichardson avatar Mar 29 '21 21:03 HaydenRichardson

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

HaydenRichardson avatar Mar 29 '21 21:03 HaydenRichardson

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 avatar Mar 29 '21 21:03 HaydenRichardson

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

HaydenRichardson avatar Mar 29 '21 21:03 HaydenRichardson

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.

codetheweb avatar Apr 01 '21 00:04 codetheweb

o ok

HaydenRichardson avatar Apr 07 '21 14:04 HaydenRichardson