dgreif / ring

Unofficial packages for Ring Doorbells, Cameras, Alarm System, and Smart Lighting
MIT License
1.21k stars 163 forks source link

New auth token is not saved #1304

Closed H-a-m-i closed 1 year ago

H-a-m-i commented 1 year ago

Is there an existing issue for this?

Describe The Bug

If I store a new auth token in the Homebridge ring plugin, it is first saved normally, but after restarting Homebridge the old token is stored again. The error has existed for over a month, suddenly from one day to the other. I've uninstalled and reinstalled homebridge multiple times

To Reproduce

Homebridge > Plugins > Homebridge Ring settings > Generate New Refresh Token... Then email address and password, google authenticator... Everything works, new token is also created and saved (is displayed in JSON configuration). But after a restart, the old expired token is stored again.

Expected behavior

Save a new token so I can access the camera again

Relevant log output

No response

Screenshots

No response

Homebridge Ring Config

{
    "platform": "Ring",
    "refreshToken": "*********"
}

Additional context

I hope you can help me, I'm hardly familiar with the topic and my English isn't the best either

OS

Windows

Node.js Version

v18.12.1

NPM Version

v9.8.1

Homebridge/HOOBs Version

v4.50.5

Homebridge Ring Plugin Version

v12.0.0

Operating System

Windows

tsightler commented 1 year ago

The plugin wouldn't have any way to know what the old token was, so, if it is reverting to a previous token, the only logical conclusion is that the config is not actually saving to persistent storage. Sure, when you generate the token via the UI, it shows up in the config, but this is only the runtime, this file must also be persisted on the host.

As there are many ways to install Homebridge, it's very difficult to help, but you state that you are running Homebridge on Windows, my gut says this might be the cause. Can you provide a link to the install method you are using for this?

H-a-m-i commented 1 year ago

OK. It's just weird because it worked fine for a year or two. Here is the link to the install method: https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Windows-10

tsightler commented 1 year ago

OK. It's just weird because it worked fine for a year or two.

Sure, but almost nothing has changed in the plugin in this regard as well, the code for updating the config dates back years with only very minor changes during that time, and there are no similar reports even though this project has 1000s of users. Certainly other parts of you infrastructure has changed.

Do you show any errors in the homebridge log?

There should be a config.json file at %HOMEPATH%\.homebridge\config.json do you see that file there and, after you generate a token via the web UI does it show the same token as shown the homebridge UI?

H-a-m-i commented 1 year ago

Hmm ok.

I have now manually created a new token with npx -p ring-client-api ring-auth-cli and stored it in the Homebridge JSON. It is then also stored in %HOMEPATH%\.homebridge\config.json. But after a restart, the old token is stored everywhere again.

I can't find any errors. homebridge_log.txt

tsightler commented 1 year ago

Are you 100% sure it is the old token? The token will not stay the same as the one that is generated, it is expected to change on first connection of the plugin to the API, so that part is normal. What is not clear is how it could possibly be reverting to an older/previous token as that doesn't even seem like it should be possible.

H-a-m-i commented 1 year ago

Oh sorry, you're right! I only ever saw the last few characters and they were always the same. There are always others, but not the generated one

tsightler commented 1 year ago

OK, then please clarify what problem you are having as it's not expected that the token would stay the same as the one originally generated, the code automatically updates the token as it is refreshed, which happens on initial connection and every hour, and also encodes additional persistent data, such as the generated system ID and the firebase cloud messaging credentials, into the token, thus the token changing from the initial generated token is fully expected and actually required.

H-a-m-i commented 1 year ago

I have now uninstalled everything again, this time really everything, including node from the pc. I also deleted all folders in windows, node, npm, homebridge, appdata, really everything. Then I reinstalled everything clean, but that didn't help either. I am at my wits end and don't know what else to do. So I have to leave it as it is and will have to do without the recordings in the future.

Thank you very much anyway

H-a-m-i commented 1 year ago

I tried again today. I uninstalled homebridge via cmd with npm uninstall -g --unsafe-perm homebridge-config-ui-x, deleted everything in $HOME\.homebridgeNode.js, uninstalled nodejs, deleted npm folder... Then did I reinstalled homebridge, but this time with Hyper V and using these instructions: https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Windows-10-Using-Hyper-V

I then also created a new homebridge account (which probably wouldn't have mattered) and then installed the ring plugin and created a new Thoken. But it's the same problem again as it has been all along. That can't be, previously via node.js and now another method with Hyper-V virtual switch, but still the same problem.

Can you give me a hint? Is there a common folder or program in Windows that is used for both methods that I can delete/uninstall/reinstall? After all, they are two different methods using two different virtual servers, but both have the same error

tsightler commented 1 year ago

What is the error? What problem are you having? You just keep explaining all the steps you are taking but never describe what problem you are actually having. You titled this post as "New auth token is not saved" but, as you noted just a few comments above, this was not the case and the token is being saved is not the same token as the one generated, but rather a new token, which is totally expected behavior. The token will never just stay the same as the one you originally generate, if it did, that would be the broken behavior.

Please describe the what problem you are having, without that, it is difficult to understand how to help you. For example, when you initially generate the token, does it work, but then not work after a reboot? Without a description of the actual symptoms you are having, there's not much path forward.

H-a-m-i commented 1 year ago

Ohhh sorry, I misunderstood your previous answer. I thought that the token should remain stored at least in the plugin on the dashboard. In that case, I'll have to look elsewhere to find out why my Ring System isn't working anymore. sorry and thank you

tsightler commented 1 year ago

If you want to open a new issue and describe the problem you are having, as well as provide logs, I'm happy to try to help, but without this, it is just a blind guessing game.