Comments (2)
One step would be to use something way newer the 9.23.0, latest version is 13.1.0. Nothing that old has been tested in a very long time and there are many updates to token handling due to changes in Ring API. You will not have much success with such an old version.
Changes to the token while the connection is active should not matter, the token is automatically updated in-memory and you don't need to care about this. The consuming code must monitor onNewRefreshToken so that it can save these new tokens for a future new connection.
You didn't share your code, just some random logs that only you can understand (clearly not from ring-client-api). Attempting to interpret your logs in the absence of other information, it appears to show new connections, but it's not at all clear why you keep reconnecting to Ring. This is not required, once the API client is connected, you can just reuse the connection without concerning about the token.
Your example was this:
- Create an API Client <-- Not sure how you are creating an API client without already having a token
- npx -p ring-client-api ring-auth-cli
- Subscribe to ring.onRefreshTokenUpdated and listen for any events
- if event, update persistence with new token, delete old one.
- Use auth token to call getCameras - get success
- Use auth token to call getCameras - get Auth error
But to me the flow is more like this:
- npx -p ring-client-api ring-auth-cli - get a token and store it in the persistent file
- Create an API Client using token from persistent file
- Subscribe to ring.onRefreshTokenUpdated and, on new event, replace the token in the persistent file
- Use API client and getCameras - get success
- Use API client and getCameras - get success
If at any point the connection is closed, create a new API Client using the last token saved in the persistent file, that is all.
A new token will be generated every time you make a new connection, but that should not matter as you should only need to make a new connection if the prior code has existed.
from ring.
@tsightler Thanks for your feedback and insight
You were right, the issue was I was creating a new ring client for each request. I guess this isn't the correct pattern. I'll raise a PR with a note for the Wiki to make this more explicit.
The fix for me was to add a new InitRing function which called the RingAPI class at start up and then a getter for whenever I actually wanted to use it.
Didn't need to upgrade the version (although I will!)
Appreciate the help!
from ring.
Related Issues (20)
- The Programmable Switch for Ring doorbells does not trigger anymore since a few days? Perhaps Update 17.1 for IOS? HOT 3
- Ring W HOT 2
- Alarm Window & Door Contact Sensor Button to Trigger a HK action HOT 1
- Does not seem to handle deactivated cameras HOT 2
- No notification in apple home app HOT 4
- Front Door Camera no longer showes AppleTV Motion Notification HOT 9
- Lost all cameras in Homekit HOT 1
- RING DOOR - Videostream closed HOT 5
- unbridgeCameras HOT 1
- Failed to reach Ring server Refresh Token : HOT 1
- Failed to reach Ring server at https://oauth.ring.com/oauth/token. fetch is not defined. HOT 1
- Still getting "Please add ['Camera' xxxx] manually in Home app" message in Log File HOT 2
- Intercom HOT 2
- Allow Setting Fixed Ports For Unbridged Cameras HOT 1
- Intercom - Bridge in the Home app stuck on connecting HOT 2
- camera.streamVideo doesn't output any video files anymore HOT 3
- can't get devices list HOT 3
- Programmable Switch Event shows but doesn't change when doorbell is ringing HOT 3
- Can't run ring-client-api on my ubuntu server. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ring.