Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rykm48 opened this issue Oct 18, 2024 · 6 comments
Open

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

rykm48 opened this issue Oct 18, 2024 · 6 comments

Comments

@rykm48
Copy link

rykm48 commented Oct 18, 2024

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
Copy link
Owner

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

const data = response.data;

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

@rykm48
Copy link
Author

rykm48 commented Oct 19, 2024

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

@rykm48
Copy link
Author

rykm48 commented Oct 19, 2024

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
Copy link
Owner

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
Copy link
Author

rykm48 commented Oct 19, 2024

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
Copy link
Owner

Great, you're welcome and happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants