Refresh token is not valid. Unable to authenticate with Ring servers #1402
-
I was able to obtain the refresh token through the ring-auth-cli, but not sure I'm copying it to the right file. I tried copying it to a config.json in the same project directory where api-example.js is located. Later copied it to an .env file in the same directory (probably ignorant on my part), but in both cases get this
Tried searching this forum and others via Google but could not find a solution EDIT: added some logging to the api-example script and it's an environment issue. the refresh token env variable is undefined, so working on that now |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The examples all use dotenv to read the configuration from a .env file. You can find a full example project here which includes instructions on how to set the .env file with the token. These are simple examples, you can choose to store and update the token however you like. |
Beta Was this translation helpful? Give feedback.
-
This is almost always caused by not saving the initial updated token, but instead trying to use the original token. Listening for onRefreshTokenUpdated events and saving the new token is absolutely critical, especially for the very initial connection, otherwise, you will find that push notification only work the very first time. Once an initial auth token is used, if you didn't save the updated token that is immediately returned on initial connection, push notification will not work again until you delete the device from Ring Control Center, recreate a new token, and save the token correctly the next time. It seems most users do not understand the criticality of this step. The reason this is important is because the ring-auth-cli tool only generates the refresh token needed for connecting to Ring API, however, the first time you actually use the token to make a connection to the Ring API, the code also generates a device registration to receive Firebase push notifications and re-encodes this data into the updated refresh token. This MUST BE SAVED at this point, if it is not, future attempts to connect to the Ring API will not be able to receive push notifications. |
Beta Was this translation helpful? Give feedback.
The examples all use dotenv to read the configuration from a .env file. You can find a full example project here which includes instructions on how to set the .env file with the token. These are simple examples, you can choose to store and update the token however you like.