BioDrop icon indicating copy to clipboard operation
BioDrop copied to clipboard

Fix needed for the rate limit issue in the GitHub API endpoint 'users/{userName}' within the 'getLocationByUsername.js' file

Open raviraj-github opened this issue 3 years ago • 6 comments

Description

During my code analysis, I discovered that we are utilizing the GitHub API "https://api.github.com/users/{userName}" and employing the Octokit utility provided by GitHub for making the API calls.

However, I noticed that we are not supplying an authentication token when creating the Octokit object. This is crucial because the API has a rate limiter implemented, which restricts the number of user reads to 60 per hour. Given our requirements, this limit is insufficient.

Here is a screenshot of the relevant code for reference from "getLocationByUsername.js".

image

See the error while loading the test data.

image

Proposed Solution:

According to the GitHub rate limiter guidelines, if we include an authentication token when making requests to this API, we will be allowed to make up to 5000 requests per hour. This limit appears to be acceptable for the current situation. However, as the number of users grows, we may need to reconsider this aspect in the future.

To address this issue, let's fix it by adding an authentication token as shown below:

image

Have a look into detailed documentation for rate limit from GitHub https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting

Screenshots

No response

Additional information

Please consult the following document, Authentication Doc, for detailed instructions on the necessary steps to implement token authentication. This guide outlines the specific procedures required to obtain and utilize the token for reading purposes.

Screenshot for generating the token-

image

More reference: Follow this youtube video for step by step process.

How to use GitHub REST API

Happy Coding!

raviraj-github avatar Jun 10 '23 07:06 raviraj-github

To reduce notifications, issues are locked until they are https://github.com/EddieHubCommunity/LinkFree/labels/%F0%9F%8F%81%20status%3A%20ready%20for%20dev and to be assigned. You can learn more in our contributing guide https://github.com/EddieHubCommunity/LinkFree/blob/main/CONTRIBUTING.md

github-actions[bot] avatar Jun 10 '23 07:06 github-actions[bot]

The issue has been unlocked and is now ready for dev. If you would like to work on this issue, you can comment to have it assigned to you. You can learn more in our contributing guide https://github.com/EddieHubCommunity/LinkFree/blob/main/CONTRIBUTING.md

github-actions[bot] avatar Jun 10 '23 23:06 github-actions[bot]

Good spot Ravi 👍

Someone can add this to the environment variables GITHUB_API_TOKEN 💯

eddiejaoude avatar Jun 10 '23 23:06 eddiejaoude

can I work on this?

Ankur1493 avatar Jun 11 '23 02:06 Ankur1493

Sure @Ankur1493 , assigned to you

eddiejaoude avatar Jun 11 '23 02:06 eddiejaoude

Thank you for submitting your pull request. I have included a review comment that requires your attention. Additionally, for this particular change, please update the documentation to reflect the modifications. It may also be necessary to provide instructions on generating tokens, if applicable.

Furthermore, please provide details on how you verified this change. In my case, I identified this issue by utilizing additional logs during the test data reload process. I recommend adding extra logs while reloading the test data, specifically within the /api/system/reload?secret=development endpoint. You can refer to the reload.js file for the location API call implementation.

raviraj-github avatar Jun 11 '23 05:06 raviraj-github