gtalusan / eufy-device-id-js

This Javascript program allows you to obtain the device ID & local key for your Eufy devices without having to rely on running an old version of their Android app.
0 stars 0 forks source link

TypeError: Cannot read properties of undefined (reading 'id') #2

Open rykm48 opened 1 month ago

rykm48 commented 1 month ago

when i run hbadmin@homebridge-ubuntu:~/eufy-device-id-js$ node index.js "myemail@gmail.com" "mypassword" i get the following error message

Error: TypeError: Cannot read properties of undefined (reading 'id') at EufyHomeSession.login (/home/hbadmin/eufy-device-id-js/lib/clients.js:77:63) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async EufyHomeSession._request (/home/hbadmin/eufy-device-id-js/lib/clients.js:84:13) at async /home/hbadmin/eufy-device-id-js/index.js:14:22

gtalusan commented 1 month ago

You can modify the code to figure out what the response is from the API

https://github.com/gtalusan/eufy-device-id-js/blob/d7e95bc6a031f26f260058f53351c9568035574b/lib/clients.js#L76

Put in a console.log and maybe there’s an error.

rykm48 commented 1 month ago

where do i put im console.log? im not sure what to type where

rykm48 commented 1 month ago

the exact steps i did to get this far is in ubuntu terminal git clone https://github.com/gtalusan/eufy-device-id-js cd eufy-device-id-js npm install and then ran node index.js "myemail@gmail.com" "password123"

gtalusan commented 1 month ago

Not sure if Copilot is doing something wrong or what... but look for this code:

    async login() {
        const response = await this.session.post(this.url('user/email/login'), {
            client_Secret: EUFY_CLIENT_SECRET,
            client_id: EUFY_CLIENT_ID,
            email: this.email,
            password: this.password
        });

        const data = response.data;
        this.session.defaults.headers['uid'] = data.user_info.id;
        this.session.defaults.headers['token'] = data.access_token;
        this.base_url = data.user_info.request_host;
    }

This is in the file clients.js, in the class EufyHomeSession (which Copilot claims to not exist). Find:

const data = response.data;

and change to:

const data = response.data
console.log(data);

and re-run it.

rykm48 commented 1 month ago

found it, thank you!! log told me my login was incorrect however i know the password is correct, upon looking in the eufy app i forgot to add the +eufy to my email address in my password manager

gtalusan commented 1 month ago

Great, you're welcome and happy to help!