dgreif / ring

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

Can't run ring-client-api on my ubuntu server. #1493

Closed kevinmym closed 3 weeks ago

kevinmym commented 3 weeks ago

Is there an existing issue for this?

Describe The Bug

I can't find a way to connect to my ring account on my ubuntu server. On my mac I get a connection in the node server I made, but on the server it just can't get through the authentication.

This happens when starting my server (first time with this token generated on mac): Ring API service listening at http://localhost:9000 node:internal/process/promises:391 triggerUncaughtException(err, true / fromPromise /); ^

Error: Refresh token is not valid. Unable to authenticate with Ring servers. See https://github.com/dgreif/ring/wiki/Refresh-Tokens at RingRestClient.getGrantData (/home/ring-service/node_modules/ring-client-api/lib/rest-client.js:140:15) at RingRestClient.getAuth (/home/ring-service/node_modules/ring-client-api/lib/rest-client.js:143:32) at RingRestClient.getAuth (/home/ring-service/node_modules/ring-client-api/lib/rest-client.js:184:29) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.17.0

This happens when trying to run the npx -p ring-client-api ring-auth-cli command: root@FlaskServer:/home/ring-service# npx -p ring-client-api ring-auth-cli\

This CLI will provide you with a refresh token which you can use to configure ring-client-api and homebridge-ring. Email: ***** Password: **** TypeError: Cannot use 'in' operator to search for 'error' in

406 Not Acceptable

406 Not Acceptable


openresty

at RingRestClient.getAuth (/home/ring-service/node_modules/ring-client-api/lib/rest-client.js:186:119)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

To Reproduce

No response

Expected behavior

I would expect the ring client to start running, as it does on my mac.

Relevant log output

No response

Screenshots

No response

Additional context

No response

OS

Linux

Node.js Version

V20.17.0

NPM Version

v10.8.2

ring-client-api

v12.1.1

Operating System

Ubuntu

tsightler commented 3 weeks ago

You should not attempt to use tokens generated on one system on a different system. Tokens contain not just the refresh token, but also encode information about the hardware ID into the string. The behavior of attempting to connect from two different systems with the same hardware ID is "undefined" as this is not expected by Ring. The library basically has to pretend to be an Andriod device. Such devices have the benefit of having a unique hardware ID that does not change and you'd never just take the token from one Android system and move it to another.

Attempting to use a token generated from one hardware ID on another system will likely lead to the token be rejected and can lead to the system in question being blocked from authentication as it is seen by Ring as a nefarious access attempt as it's not expected that a token from one system would be used with a different hardware ID.

I'm not 100% sure this is the case here, but it's the most likely scenario since there's not really much other reason the behavior would be different between systems and there are, quite literally, 10's of thousands of users running this code on Ubuntu systems today. It's far more like that you have done something unexpected vs there being an actual bug.

If you have attempting to use a code generated on one system on a different system, you should make sure to remove this system from the Ring Control Center before performing any new authentication attempts. Also be sure to delete any static tokens you may have created. You may also need to wait several hours for any temporary blocks to be removed for that device. Good luck.

kevinmym commented 3 weeks ago

The removal of the ring account center did help running it on my Manjaro computer. But i still get the 406 error on my ubuntu server in a AMS3 droplet.

kevinmym commented 3 weeks ago

Spinned up a new droplet and i get the same error there, does anybody have experience with this issue, or someone knows what to do?

tsightler commented 3 weeks ago

My guess is Ring blocks them. Ring has large amounts of IP blocks in place from various cloud services and VPNs. Digital Ocean IP blocks are on tons of blacklists in general and Ring would have no reason to expect connections from those services. Can you try it, at least temporarily, from some other service?

kevinmym commented 3 weeks ago

For temporarily I can use my laptop running Manjaro, but a fix would be nice to use it from a server, although I can imagine that that is going to be though. Thanks for your help!

tsightler commented 3 weeks ago

We don't have any control over what Ring API blocks or does not. Plenty of people use the ring-client-api from "a server", but you are not using "a server", you are using droplets from Digital Ocean which leverage a pool of IPs well known for being the source of abuse of various types. I can't be 100% sure of that this is the cause, but 406 is typically indicative of a block (same error for blocked VPNs and for temporary blocks Ring places when incorrect credentials are retried). There's no other reason the code would not work on "a server".

Based on the fact that this is likely environmental, and not something we can control, I will close this.