Uh oh!
There was an error while loading. Please reload this page.
Validate GitHub token in authentication - #105
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds GitHub token validation to the authentication flow in lib50. The change helps detect invalid or expired GitHub tokens early in the authentication process, particularly for users working in CS50 Codespaces.
Changes:
- Added a new
InvalidTokenErrorexception class to represent invalid or expired GitHub tokens - Implemented
_validate_github_token()function that validates tokens by making an authenticated request to the GitHub API - Integrated token validation into the HTTPS authentication flow for Codespaces users
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| lib50/_errors.py | Added new InvalidTokenError exception class and exported it in __all__ |
| lib50/authentication.py | Added requests import, _validate_github_token() function, and integrated token validation into _authenticate_https() for Codespaces environments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.