rs1932 / ring-alarm-hassio-addon

19 stars 16 forks source link

New two-factor method #8

Open michaelbrown2 opened 4 years ago

michaelbrown2 commented 4 years ago

I don’t know if this project is still supported, but it’s been a huge help for me! I appreciate your work. I was curious, with the new ‘breeches’ with Ring if you’ve looked into incorporating the new two factor built into dgreif’s API. It looks like tsightler integrated it as well: https://github.com/tsightler/ring-alarm-mqtt/pull/34

I just don’t know how to pass the refreshToken from inside your config to the underlying script. I’d be happy to test if you do decide to try this out, as until then (or I implement the script on me own), my automations no longer work! Thanks!

plw4 commented 4 years ago

I cloned this repository and changed the config.json to use the extra options from tsightler's program. Then turned on 2fa, generated a code, and it's working.

The problem is generating that code. I feel like a lot of hassio users run on a Pi and won't have access to a shell to run the program to generate the code. I haven't been able to figure out if the code is stored in a human readable format somewhere in HA's files so that we could just reuse the code from the official Ring integration.

broyuken commented 4 years ago

@plw4 could you take a look at my repo? I did the same but it isn’t working. Where did I go wrong?

plw4 commented 4 years ago

Are you getting that "ring-alarm-mqtt Exit code: 1" error? Is the token you have like 392 characters long?

broyuken commented 4 years ago

It’s pretty damn long yea and yes exit code 1

plw4 commented 4 years ago

The only thing different I did was add the location_ids variable, but I leave it blank. Username and password are also blank with the token.

{
  "host": "192.168.0.3",
  "port": 1883,
  "ring_topic": "ring",
  "hass_topic": "hass/status",
  "mqtt_user": "!secret mqtt_username",
  "mqtt_pass": "!secret mqtt_password",
  "ring_user": "",
  "ring_pass": "",
  "ring_token": "!secret ring_api_token",
  "location_ids": [
    ""
  ]
}
broyuken commented 4 years ago

Weird, I added that as well and now it works, I originally left it out because I didn't think it would be necessary. Anyways, I have created a pull request, let's hope it gets pulled in, otherwise I'll stick to my repo :)

Thanks for the help!

davidadanieljr commented 4 years ago

Just started getting the exit code 1 error after upgrading to 0.105.2. I tried reverting back to .0 but the error persists. Ive changed nothing in the addon configuration settings. I'm using the hassio integration. Would anyone be willing to share how to get the ring token generated? Inwould greatly appreciate it.

jac2424 commented 4 years ago

Two factor authentication is now mandatory. Anyone have instructions on how to get working?

tsightler commented 4 years ago

Instructions to get a refresh token: https://github.com/dgreif/ring/wiki/Two-Factor-Auth

Note that you have to do this manually from the command line with the tool from the Ring API (not really related to this project or my script).

simpat1zq commented 4 years ago

@tsightler does this addon have the latest code from your integration? Will this addon work with 2FA?

tsightler commented 4 years ago

When you perform a "Rebuild" the addon pulls the latest code. I plan to publish an updated version of ring-mqtt soon, to replace the existing ring-alarm-mqtt completely, and this new script will include HASSIO addon support in the main tree. I was already planning to get that done next weekend, but, due to this issue, I'm going to attempt to accelerate those and get it published tonight if I can work out the last few bugs.

rumym commented 4 years ago

Any chance we can get this updated with the latest 2FA update or perhaps a workaround in the meantime. The ring-MQTT project sounds amazing and can’t wait for that however, all my automations are broken at the moment

tsightler commented 4 years ago

I'm not in control of this project so I can't answer your question. As of tonight I have published my own version of a Hass.io addon for ring-mqtt, available at https://github.com/tsightler/ring-mqtt-hassio-addon which I plan to maintain, along with the script itself, going forward. I haven't performed quite the level of testing that I would like, but it seems to work for me and I'm rushing it out the door due to this issue.

rumym commented 4 years ago

Awesome! Just installed it and tested it. Works great!

jac2424 commented 4 years ago

I'm not in control of this project so I can't answer your question. As of tonight I have published my own version of a Hass.io addon for ring-mqtt, available at https://github.com/tsightler/ring-mqtt-hassio-addon which I plan to maintain, along with the script itself, going forward. I haven't performed quite the level of testing that I would like, but it seems to work for me and I'm rushing it out the door due to this issue.

I installed the new addin but where do I run the command in hass.io to get refreshToken generated?

tsightler commented 4 years ago

Honestly, I have no idea. Part of the reason I don't use things like Hass.io is exactly because it seems to make some of this stuff more difficult. But you don't have to run it in hass.io, you can run it anywhere that you have node installed, which can be pretty much anywhere.

I'm still trying to figure out a way to do this with the addon without requiring command line. Either a simple web app, or some hackish approach. I have some ideas, but I need to do testing.

rumym commented 4 years ago

It's tough with Hassio I can't think of a solution off the top of my head but try logging into the docker container and then running the command . I happen to have hombridge installed with the ring plugin so I just ran the command there to get the 2FA token

rumym commented 4 years ago

@tsightler perhaps you can do something like what these folks did for the tesla api. I don't have the skills otherwise I would have helped

https://www.npmjs.com/package/generate-tesla-token

tsightler commented 4 years ago

I don't see how that helps as that's just another command line tool and I need interactive input so that you can enter the result. If you can get a command line you can just run the existing tool.

I have two thoughts so far, one pretty hackish, but technically easy, one probably more proper:

1) I can add one more parameter for the 2FA response, modify the run.sh script to check for a token in the config, if it doesn't have one it assumes we need to get a new one and logs in with the username/password, which will trigger a 2FA code being sent, this code simple sits a loops waiting to see the response in the config. Once you receive the 2FA code, you enter it in the config and save it, the script sees this, and generates the token. It's hackish, but I believe I could make it work.

  1. Create a small web UI as part of the add-on, which simply prompts for the username/password, then waits to enter the 2FA code and then shows the token, which you can then copy and paste into the config. This is probably the best option, but something I've not done before, so might take me a little time to add.
Grey-Lancaster commented 4 years ago

I have Hassio on a Pi and there is no way to get the token. Everyone says just run the command where you have Node, so I installed node on my Win 10 box and that does not work either I found some guys ring-api on GitHub but get does not work in a node window :)

tsightler commented 4 years ago

If you install node on Windows you should be able to run the following in a nodejs command prompt: npx -p ring-client-api ring-auth-cli

Grey-Lancaster commented 4 years ago
Welcome to Node.js v12.16.1.
Type ".help" for more information.
> npx -p ring-client-api ring-auth-cli
npx -p ring-client-api ring-auth-cli
          ^^^^

Uncaught SyntaxError: Unexpected identifier
>
well that did not paste pretty. the little error indicators are under ring

>`
tsightler commented 4 years ago

Looks like you're running Nodejs itself, you need to open a Nodejs Command Prompt. If you've installed NodeJS on windows there will be two icons, one simple starts Nodejs and leaves you at a Node prompt, the other is called "Nodejs Command Prompt" which starts a starts a standard Windows command prompt with all of the environment configured to access the node tools like "npm" and "npx". It should say:

Your environment has been set up for using Node.js 12.16.1 (x64) and npm. C:\Users\windows_username>

Grey-Lancaster commented 4 years ago

thanks, that did something

Grey-Lancaster commented 4 years ago

It works :) I setup a shared user so when I do something the notifications say by Hass Io. 888 door lock is also working. Great stuff, thanks for your help

jac2424 commented 4 years ago

Looks like you're running Nodejs itself, you need to open a Nodejs Command Prompt. If you've installed NodeJS on windows there will be two icons, one simple starts Nodejs and leaves you at a Node prompt, the other is called "Nodejs Command Prompt" which starts a starts a standard Windows command prompt with all of the environment configured to access the node tools like "npm" and "npx". It should say:

Your environment has been set up for using Node.js 12.16.1 (x64) and npm. C:\Users\windows_username>

Thank you for your new addin. I finally figured out how to get token created in windows and now its working again.

blamaz commented 4 years ago

Just tried NodeJS on Windows to get the ring token, everything is working again. Thank you for the new addon.