Skip to content

Commit a781b8b

Browse files
committed
Optionally authenticate to the GitHub API
1 parent 0ef25f6 commit a781b8b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

prefix_finder/frontend/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ def refresh_data(branch="master"):
181181

182182
try:
183183
sha = requests.get(
184-
'https://api.github.com/repos/org-id/register/branches/'+branch
184+
'https://api.github.com/repos/org-id/register/branches/'+branch,
185+
auth=(settings.GITHUB_USER, settings.GITHUB_API_TOKEN) if settings.GITHUB_USER and settings.GITHUB_API_TOKEN else ''
185186
).json()['commit']['sha']
186187
using_github = True
187188
if sha == git_commit_ref.get(branch,''):

prefix_finder/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
SECRET_KEY=(str, secret_key),
3333
DB_NAME=(str, os.path.join(BASE_DIR, 'db.sqlite3')),
3434
LOCAL_DATA=(bool, False),
35+
GITHUB_USER=(str, ''),
36+
GITHUB_API_TOKEN=(str, ''),
3537
)
3638

3739
PIWIK = {
@@ -40,6 +42,8 @@
4042
}
4143

4244
LOCAL_DATA = env('LOCAL_DATA')
45+
GITHUB_USER = env('GITHUB_USER')
46+
GITHUB_API_TOKEN = env('GITHUB_API_TOKEN')
4347

4448
# Quick-start development settings - unsuitable for production
4549
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

0 commit comments

Comments
 (0)