Fixes token expiry issues#20
Open
5E7EN wants to merge 2 commits intoKoenZomers:masterfrom
Open
Conversation
Author
|
@KoenZomers got a chance to review and merge these changes? |
danespinosa
reviewed
Apr 8, 2024
| /// Gets a DateTime with when this token expires | ||
| /// </summary> | ||
| public DateTime ExpiresAt { get; private set; } | ||
| public DateTime ExpiresAt |
Collaborator
There was a problem hiding this comment.
Hi @5E7EN thanks for your contribution, would you mind following the same pattern as the RingApi project to keep it consistent please?
https://github.com/KoenZomers/RingApi/blob/master/Api/Entities/OAuthToken.cs#L28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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