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.
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