-
Notifications
You must be signed in to change notification settings - Fork 82
Authenticated API #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Authenticated API #118
Conversation
Reviewer's GuideThis PR adds support for GitHub personal access tokens to make authenticated API calls—with higher rate limits—by storing the token, branching AJAX requests to include authorization headers, providing a masked input with toggle controls in the popup UI, styling the token field, and updating documentation. Sequence Diagram: Conditional GitHub API Call LogicsequenceDiagram
title Sequence Diagram: Conditional GitHub API Call Logic
participant Script as "scrumHelper.js"
participant Storage as "chrome.storage.local"
participant GitHub as "GitHub API"
Script->>Storage: get("githubToken")
Storage-->>Script: githubToken (or null)
alt Token is available
Script->>GitHub: GET /search/issues (Authenticated with Authorization header)
else Token is not available
Script->>GitHub: GET /search/issues (Public unauthenticated call)
end
GitHub-->>Script: API Response
Class Diagram: Updates to JavaScript Modules for Token AuthenticationclassDiagram
title Class Diagram: Updates to JavaScript Modules for Token Authentication
class scrumHelper_js {
+allIncluded() : void
+fetchGithubData() : void
}
class popup_js {
+handleTokenInputAndVisibility() : void
+loadTokenFromStorage() : void
+saveTokenToStorage() : void
}
class main_js {
+handleBodyOnLoad() : void
+handleGithubTokenChange() : void
}
class ChromeStorageService {
<<External API>>
+get(keys, callback) : void
+set(items, callback) : void
}
scrumHelper_js ..> ChromeStorageService : uses
popup_js ..> ChromeStorageService : uses
main_js ..> ChromeStorageService : uses
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @vedansh-5 - I've reviewed your changes - here's some feedback:
- The AJAX calls for public vs authenticated requests are almost identical—consider refactoring them into a helper function to reduce duplication and simplify maintenance.
- The chrome.storage.local.get inside fetchGithubData is asynchronous and doesn’t block the immediate AJAX calls, so the token may not be set in time—restructure to await token retrieval before making requests.
- Debouncing or deferring chrome.storage.local.set on the token input (e.g. on blur or with a short timeout) would prevent excessive writes on every keystroke.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The AJAX calls for public vs authenticated requests are almost identical—consider refactoring them into a helper function to reduce duplication and simplify maintenance.
- The chrome.storage.local.get inside fetchGithubData is asynchronous and doesn’t block the immediate AJAX calls, so the token may not be set in time—restructure to await token retrieval before making requests.
- Debouncing or deferring chrome.storage.local.set on the token input (e.g. on blur or with a short timeout) would prevent excessive writes on every keystroke.
## Individual Comments
### Comment 1
<location> `src/scripts/scrumHelper.js:192` </location>
<code_context>
- writeGithubIssuesPrs();
- },
- });
+ if(githubToken){
+ console.log("Making authenticated API calls-fetch github Data");
+ $.ajax({
</code_context>
<issue_to_address>
Extract repeated AJAX logic into helper
Consider creating a utility function that takes the URL and callback, handling headers as needed, to avoid duplicating similar AJAX request logic.
Suggested implementation:
```javascript
// Helper function to fetch GitHub data with authentication
function fetchGithubData(url, successCallback, errorCallback) {
$.ajax({
dataType: 'json',
type: 'GET',
url: url,
headers: {
Authorization: `Bearer ${githubToken}`,
Accept: 'application/vnd.github+json'
},
success: successCallback,
error: errorCallback
});
}
if(githubToken){
console.log("Making authenticated API calls-fetch github Data");
fetchGithubData(
issueUrl,
function(data) {
// Place your success logic here
},
function(xhr, textStatus, errorThrown) {
console.error('Error fetching GitHub data:', {
status: xhr.status,
```
- You will need to move the helper function `fetchGithubData` to a suitable location if you want to reuse it elsewhere in the file.
- Replace other similar `$.ajax` calls for GitHub API requests with this helper for full deduplication.
- Move the original success logic from the previous `$.ajax` call into the `successCallback` function in the new usage.
</issue_to_address>
### Comment 2
<location> `src/scripts/main.js:211` </location>
<code_context>
}
enableToggleElement.addEventListener('change', handleEnableChange);
githubUsernameElement.addEventListener('keyup', handleGithubUsernameChange);
+githubTokenElement.addEventListener('keyup', handleGithubTokenChange);
projectNameElement.addEventListener('keyup', handleProjectNameChange);
startingDateElement.addEventListener('change', handleStartingDateChange);
</code_context>
<issue_to_address>
Standardize on input vs keyup event
Consider using the `input` event here, as in `popup.js`, to ensure consistent UI behavior.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
githubTokenElement.addEventListener('keyup', handleGithubTokenChange);
=======
githubTokenElement.addEventListener('input', handleGithubTokenChange);
>>>>>>> REPLACE
</suggested_fix>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested this, and it is correctly making authenticated calls using your personal classic GitHub token.
Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com>
Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com>
@hpdang @mariobehling @Preeti9764 I have resolved the conflicts in this PR and moved the github Token input to settings. Please take a look whenever you can. Thanks! |
Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com>
@hpdang Changes can be cleanly merged. Please take a look. |
@vedansh-5 this looks good to me. I have the following suggestion: In the Github Token Popup window, the 1st paragraph can be replaced with the following text if you think it makes sense: Why is it recommended to add a GitHub token? |
@Preeti9764 I'm not able to test with Outlook and Yahoo, could you please help to test this as well? Thank you. |
As we can notice the subject is missing from yahoo, we have an existing issue for the same and #138 fixes it. |
@hpdang @vedansh-5 I have reviewed this pr and tried using both type of tokens fine grained tokens as well as classic tokens , the authenticated request is correctly made for classic tokens and report is generated correctly at various email-clients , but for fine grained token the report is not generated, @vedansh-5 as per the note given both should work can you please tell the details how to use the fine grained token or only to use the classic (token ) , it would be good for user if you can modify the note and explanation more clearly . Thanks! |
Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com>
I have changed the note to use only classic token, authorization headers are enough to work with fine grained tokens too, but github uses specifically |
Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com>
📌 Fixes
Implementing using of github personal tokens for authenticated api calls, limits now raised to 5000req/ip/hour.
Also added the steps on how to obtain the github personal tokens.
Fixes #105
📸 Screenshots / Demo (if UI-related)
Add screenshots, video, or link to deployed preview if applicable


✅ Checklist
Summary by Sourcery
Add support for authenticated GitHub API calls using personal access tokens to increase rate limits, including UI enhancements for token input and visibility control, token persistence, and fallback for unauthenticated requests.
New Features:
Enhancements:
Documentation: