Closed edcarvalholine closed 2 years ago
I think you just have a problem in your _getToken function. It should be:
const _getToken = async () => {
return await tapoHandler.loginDeviceByIp(
user.email,
user.password,
"192.168.1.15"
);
};
Closed presumably resolved
I want to keep a device's token until it expires to avoid always requests to tapo API
I thought about this code
but as soon as I try to get it gives me the error below
(node:10324) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received undefined at new NodeError (internal/errors.js:322:7) at prepareSecretKey (internal/crypto/keys.js:322:11) at Cipheriv.createCipherWithIV (internal/crypto/cipher.js:119:9) at new Cipheriv (internal/crypto/cipher.js:227:22) at Object.createCipheriv (crypto.js:124:10) at Object.encrypt (C:\Users\nain\Desktop\tapo-automatted\node_modules\tp-link-tapo-connect\dist\tplinkCipher.js:70:35) at C:\Users\nain\Desktop\tapo-automatted\node_modules\tp-link-tapo-connect\dist\api.js:292:51 at step (C:\Users\nain\Desktop\tapo-automatted\node_modules\tp-link-tapo-connect\dist\api.js:44:23)
But if I put the token to be called every time I invoke a device function, it doesn't give an error