KoenZomers / RingRecordingDownload

Console Application for Windows, Raspberry Pi, Linux and macOS which allows for downloading of Ring recorded events
Apache License 2.0
20 stars 9 forks source link

Fixes token expiry issues #20

Open 5E7EN opened 8 months ago

5E7EN commented 8 months ago

The logic that checks for token expiry was not using a valid datetime since the assignment is broken in the OAuthToken implementation. After getting a token response from the auth endpoint, the program was never setting the expiry date to the OAuthToken class, so any check for token expiry would always return true.

As a result, any calls to the EnsureSessionValid() method triggered a token refresh for each video download, causing the API to eventually throw a "too many token requests" error.

This PR adds a new property in the OAuthToken class to store the actual expiry date as provided by the auth API when the request for a token is made. This enables expiry validation to return accurate results.

Closes #17

5E7EN commented 8 months ago

@KoenZomers got a chance to review and merge these changes?