diff options
author | 2021-05-23 16:17:10 +0100 | |
---|---|---|
committer | 2021-05-23 16:17:10 +0100 | |
commit | a3c96d2e92af9004450b746ec27137a2e7aa256e (patch) | |
tree | 9abd0156c340adfefa62eccefd090b484fd496f9 /pydis_site | |
parent | Merge pull request #507 from python-discord/faq-update (diff) |
Authenticate with the github api to avoid rate limits
Diffstat (limited to '')
-rw-r--r-- | pydis_site/apps/home/views/home.py | 4 | ||||
-rw-r--r-- | pydis_site/constants.py | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/pydis_site/apps/home/views/home.py b/pydis_site/apps/home/views/home.py index e77772fb..b3767d37 100644 --- a/pydis_site/apps/home/views/home.py +++ b/pydis_site/apps/home/views/home.py @@ -9,6 +9,7 @@ from django.utils import timezone from django.views import View from pydis_site.apps.home.models import RepositoryMetadata +from pydis_site.constants import GITHUB_TOKEN log = logging.getLogger(__name__) @@ -18,6 +19,7 @@ class HomeView(View): github_api = "https://api.github.com/users/python-discord/repos?per_page=100" repository_cache_ttl = 3600 + headers = {"Authorization": f"token {GITHUB_TOKEN}"} # Which of our GitHub repos should be displayed on the front page, and in which order? repos = [ @@ -42,7 +44,7 @@ class HomeView(View): repo_dict = {} # Fetch the data from the GitHub API - api_data: List[dict] = requests.get(self.github_api).json() + api_data: List[dict] = requests.get(self.github_api, headers=self.headers).json() # Process the API data into our dict for repo in api_data: diff --git a/pydis_site/constants.py b/pydis_site/constants.py index c7ab5db0..e6a63d12 100644 --- a/pydis_site/constants.py +++ b/pydis_site/constants.py @@ -1,3 +1,4 @@ import os GIT_SHA = os.environ.get("GIT_SHA", "development") +GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN") |