Validate GitHub token in authentication #105
Merged
+98
−3
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.
This PR adds validation for GitHub tokens during authentication to ensure users are notified if their token is invalid or expired.
Authentication improvements:
_validate_github_tokenfunction inlib50/authentication.pythat makes an authenticated request to the GitHub API to verify the provided token, raisingInvalidTokenErrorif the token is invalid or expired._authenticate_httpsfunction inlib50/authentication.pyto call_validate_github_tokenafter obtaining the token, and to handle invalid tokens by notifying the user, logging out, and exiting.Error handling enhancements:
InvalidTokenErrorclass tolib50/_errors.pyfor signaling invalid or expired GitHub tokens, and updated the error exports accordingly. [1] [2]lib50/authentication.pyto includeInvalidTokenError.Dependency and version updates:
3.2.1insetup.pyto reflect these changes.requestsimport inlib50/authentication.pyfor making HTTP requests to the GitHub API.