jeroenterheerdt / ring-hassio

A Home Assistant add-on for live streaming from Ring devices.
MIT License
132 stars 93 forks source link

Two Factor Authentication #11

Closed Devqon closed 4 years ago

Devqon commented 4 years ago

Hi,

Thank you for this great add-on, it is what I was looking for a long time!

I cannot seem to get it to work however. After starting the addon I get the following error:

[services.d] done.
(node:195) UnhandledPromiseRejectionWarning: Error: Your Ring account is configured to use 2-factor authentication (2fa).  See https://github.com/dgreif/ring/wiki/Two-Factor-Auth for details.
    at RingRestClient.<anonymous> (/ring-hassio/ring_hassio/node_modules/ring-client-api/lib/api/rest-client.js:121:27)
    at Generator.throw (<anonymous>)
    at rejected (/ring-hassio/ring_hassio/node_modules/ring-client-api/lib/api/rest-client.js:6:65)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
(node:195) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:195) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[cmd] /ring-hassio/ring_hassio/run.sh exited 0

The page linked doesn't exist, but after digging through the issues in the used library I found that Ring has enabled 2FA by default, and it should now work through an access token (see https://github.com/dgreif/ring/issues/256 and https://github.com/dgreif/ring/wiki/Refresh-Tokens). The only option in this add-on however is to input username and password.

How can I get it to work with the refresh tokens?

jeroenterheerdt commented 4 years ago

Hi, sorry, I kind of abandoned this for a long time since I was burning the Rings battery. The addon needs updating to support 2FA which became a requirement after I abandoned this. Also, the livestream is 24 hour as I don't have a way to figure out if HA is showing it or not. If we all start doing that Ring will cut us off quickly. Anyhow, I was planning on looking at supporting 2FA soon since I have hooked up my Ring to power now.

Devqon commented 4 years ago

Looks like someone else already (tried to) implement it in a fork of your repository: https://github.com/Harryjholmes/ring-hassio-live

I'm going to try it out and report back here. If it works it would be cool if @Harryjholmes would create a pull request for this functionality to bring it here.

HarryJHolmes commented 4 years ago

Yeah it does work @Devqon

HarryJHolmes commented 4 years ago

I got it all working the biggest issue being that it’s streaming 24/7 and like @jeroenterheerdt Im not sure how to make it work on demand?

Devqon commented 4 years ago

@Harryjholmes cool that it works. I am still getting errors on the refresh token, but I might be doing something wrong. If I can get it to work I'll try to dive into the on-demand issue.

[services.d] done.
(node:193) UnhandledPromiseRejectionWarning: Error: Failed to fetch oauth token from Ring. Verify that your refresh token is correct. invalid_grant
    at RingRestClient.<anonymous> (/ring-hassio/ring_hassio/node_modules/ring-client-api/lib/api/rest-client.js:129:23)
    at Generator.throw (<anonymous>)
    at rejected (/ring-hassio/ring_hassio/node_modules/ring-client-api/lib/api/rest-client.js:6:65)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
HarryJHolmes commented 4 years ago

12 for pull request

jeroenterheerdt commented 4 years ago

Thanks a lot both of you! Looking forward to bringing this back to life.

Devqon commented 4 years ago

Awesome I've got it working. One question (maybe this issue is not the correct spot); do I really need to open up port 3000 on my router too? Does the ring api use it or is it just to be able to connect to the stream from outside my network?

HarryJHolmes commented 4 years ago

I never opened it for inbound traffic only outbound @Devqon