denniedegroot / com.ring

Ring for Homey
https://www.athom.com
Other
15 stars 15 forks source link

Losing authentication v2.2.0 (2FA edition) #51

Closed Genghes closed 4 years ago

Genghes commented 4 years ago

Hi. Installed and running the 2.2.0 version. (@kaohlive version ;) #46 ) The authentication works fine, but after a couple of minutes/ hours the authentication drops. A restart of the app works as a workaround.

Here is a exerpt from the log when this happens:

_refreshDevice _https /dings/active 2020-03-09 17:43:43 [log] [ManagerDrivers] [doorbell] [0] _syncDevice [] _refreshDevice _https /dings/active 2020-03-09 17:43:48 [log] [ManagerDrivers] [doorbell] [0] _syncDevice [] _refreshDevice _https /dings/active 2020-03-09 17:43:53 [log] [ManagerDrivers] [doorbell] [0] _syncDevice [] _refreshDevices _https /ring_devices _https : invalid_authentication : 401 {"error":"Unauthorized", "status_code":401} _refreshDevice _https /dings/active _https : not_authenticated _refreshDevice _https /dings/active _https : not_authenticated _refreshDevice _https /dings/active _https : not_authenticated

kaohlive commented 4 years ago

make sure you get the latest version from dennies version. this issue was present in my first pull but it should be fixed a day later. i have been running it now for a week without any reauthorization requirements.

Genghes commented 4 years ago

Ahh.. Thats how it goes when I test and forget to check for newer releases.

Just checked ant the 2.2.2 version is Live on Athom. So I will install that on my production Homey.

Genghes commented 4 years ago

Closing Issue, Probably fixed. No need to keep this ticket open.

Patrick1610 commented 4 years ago

I do keep having this problem with the 2.2.2 version.. The app does say it's authenticated, but when I test I flow I get an error.. image

Screenshot 2020-03-15 at 11 36 29
kaohlive commented 4 years ago

If you try to add a new device, what do you get then? does it end with no devices available or with an error?

Patrick1610 commented 4 years ago

I have already added al my devices successfully, so now I get the ‘No new devices found’ text.

kaohlive commented 4 years ago

but that means the authentication still works. Else you would get an error there. So its amother problem I am afraid. Image grabbing unique maybe. Do you get generic alarms when the bell has been used? or do they also fail

Patrick1610 commented 4 years ago

No I don’t get generic alarms, nor do I get motion alarms. Basically, only the device adding works..

kaohlive commented 4 years ago

so you have mfa enabled and while authorizing you received your token and submitted it. then you add you devices and the first few hours it works, but later you get unauthorized in the grab image (easy to test instead of alarms). Alarms no longer work either. Re-authorization enables working again for a few hours. after these hours you still can complete the add device wizard.

good summary?

Patrick1610 commented 4 years ago

Perfect summary! The ‘add device wizard’ was enough to reauthenticate and get everything working for a while (even grabber).

Any idea what could be the cause of the problem?

kaohlive commented 4 years ago

no, not if you are using the app version from the homey store and not my first fork. Sounds exact the issue i fixed later on and is in the 2.2.2 version. very strange. there is a timer that checks and refreshes now, before it was after app restart and device adding. the device adding wizard did not ask you to reauthenticate?

Patrick1610 commented 4 years ago

Yes, I am. I have never installed a fork or anything. I had the previous app. Installed this one and uninstalled that one. Later I even uninstalled the 2.2.2 and reinstalled to check if that fixed the problem :(

Each time I entered the device wizard it asked for authentication

kaohlive commented 4 years ago

then you are loising the refresh token indeed. very strange.

Patrick1610 commented 4 years ago

I have just tried adding a new device again, and it didn’t ask for authentication again, so it seems to work :)

kaohlive commented 4 years ago

ok lets keep track, see if it gets lost again.

Raycokes2000 commented 4 years ago

i hoped v2.2.2 2fa would work properly, but it still does not, there is no input field for the code sent unfortunately. after remove and reinstall there was a input field but later says no new devices. Will continu to remove all, restart homey, report back asap here

kaohlive commented 4 years ago

so you revoked the auth in app settings? then went into add device, select ring, a device type and got the new authentication page. enter credentials, press login, get a code entry box enter the just received code into the box and authorize. but you do not get the code box in that step?

kaohlive commented 4 years ago

posys crossed, you wouldn't see a new device if you still have all devices registered, that is not bad. it should work from that point also on those devices. if you removed your r devices from homey you should see them at the end of the wizard. else something went wrong during login.

Raycokes2000 commented 4 years ago

could not even revoke, older version was not auto updated, so did this myself, then got 2 version, so now cleaning up. old flow gone, app gone, reboot homey. now going blank with this app again. looked like cluster fuck app with app versions.

Raycokes2000 commented 4 years ago

still nothing unfortunatley, after 2fa code, says no new device found. any hints would be nice to solve this, even after restarts no solution. device were removed, no login probs, 2fa was okay etc.

kaohlive commented 4 years ago

if you can generate a log and send it i coupd take a look. if you go through the add device wizard again, do you have to authorize again or does that step get skipped now?

Raycokes2000 commented 4 years ago

authorize is skipped, allready approved, yoy see shortly that screen then skips and says no new devices found 76a44799-f2cc-43eb-9b0a-0c8d27448069 what does it need to say at apps ring, settings, my ring authorise here says, error you need to authenticte from add device wizard! that was already done

kaohlive commented 4 years ago

so the add device wizard is acting like its properly authorized but you are missing a device that is not present in your homey yet. sinse no device just suggest all your device are added to homey already. without the log i can not help you determine why you are missing devices OR that homey thinks they are already registered (maybe from the old dubble app) but its not an mfa issue as far as i xan tell. maybe best to open a new issue for this one. but i would check the e homey dev screen first and list your registered devices there. ensure your ring device is not there already

Raycokes2000 commented 4 years ago

ok, but you need logging now? whee is extra logging for you available, you have diag report, and a new issue? no ring device in dev list. double app was removed earlier

Raycokes2000 commented 4 years ago

in there a way to remove authorisation? can not see that now. and can it be a non admin account? there could be a issue as wel i gues. first versions had issues with non admin or owner accounts

kaohlive commented 4 years ago

i am not the app publisher so i get no logs when you send them, not sure how you can share them now. you should be able to revoke in the app settings. but you stated that screen tells you its not authorized. so something weird is still going on in your deployment. on what homey version are you?

Patrick1610 commented 4 years ago

ok lets keep track, see if it gets lost again.

Well, unfortunately the connection is lost again.. :(

Raycokes2000 commented 4 years ago

@kaohlive sorry for delay, v2.2.2

Raycokes2000 commented 4 years ago

after several reboots, revoked authorisation, but stil after adding nothing happened. is shared user accepted of doet is need to be admin user required? i rather not use such account in homey

Genghes commented 4 years ago

For your information. I have used the v2.2.2 for several weeks and it works perfectly. Tried it om two homeys, Pro and Standard.

I Have given it my only Ring login, not a shared, but I dont think that should be an issue.

Be aware that if you have disabled Motion or Ring alerts in the Ring app they will not register in Homey app as well. (If you hav snoozed or by schedule in Ring app the same goes for Homey.)

Try enabeling ALL in the Ring app.

Also be aware Ring has TWO different 2FA. One they just forced on everyone and one you can enable in the account. You have to Enable 2FA in the Ring Account (Even if Ring forced it on your account)

And the account: It's no problem giving the app the Admin account. The app that account just to get a token and then use the token when connecting after that. I don't think the password is stored in Homey anyway. Correct me if I'm wrong @kaohlive @denniedegroot

kaohlive commented 4 years ago

i am also using my admin account. And you are correct we only store the refresh token and keep the temo access token in memory and no account info is stored at all.

Genghes commented 4 years ago

I also had problems when Ring forced 2FA. But loggin in to Ring.com I saw 2FA NOT ENABLED. So even if they have forced 2FA on it is NOT ON when you veiw your account information.

After logging in to Ring.com (with 2FA) ?!? and then enabeling 2FA everything worked.

kaohlive commented 4 years ago

Hi @Genghes , @Patrick1610. @Raycokes2000 , I think I identified when this fails. In case of the grabimage and its receives a not found error the code threats this as a failed authentication reason. Tries to refresh and still gets an error, than it marks the app as unauthenticated. Ill make some code to handle this scenario as a not found for the grabsnaphot action.

kaohlive commented 4 years ago

Just commited a fix (I think) in my fork. Ill create a new pull request for @denniedegroot All I did was add a check on 404 to still give an error to the flow card but with resource not found instead of invalid credentials and it does not invalidate the authentication as a next step.

Patrick1610 commented 4 years ago

Hi @Genghes , @Patrick1610. @Raycokes2000 , I think I identified when this fails. In case of the grabimage and its receives a not found error the code threats this as a failed authentication reason. Tries to refresh and still gets an error, than it marks the app as unauthenticated. Ill make some code to handle this scenario as a not found for the grabsnaphot action.

Amazing you found and fixed the problem!! Just curious, what could be the cause that no snapshot can be grabbed, if the connection/authentication is solid?

kaohlive commented 4 years ago

what i understand from that api its not a trigger to make a snapshot, it just downloads the most recent one after checking for a fresh one. maybe that check should trigger the device to make one not sure. but today it suddenly started to give a 404 on my device, but during debugging those dissapeared again. So it may be something as silly as ring restarting a service or something. or how often you use your live view. no real idea.

Raycokes2000 commented 4 years ago

2fa is no problem here anymore, rebooted several times and used admin account/main user accont and now it works but 2.2.3 is not workingen properly my flow do not work after this update

kaohlive commented 4 years ago

what 2.2.3 version did you take, the one from the test link or from github and installed using cli? i see no reason why your flows might have stopped, some people reported that ring disabled alerts. check to see those are active please