From ad857ab719814a797647f1dccfd05f8039cbb236 Mon Sep 17 00:00:00 2001 From: agatha Date: Fri, 10 Nov 2023 21:33:29 -0500 Subject: [PATCH] Add support for access token --- gitmon/api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gitmon/api.py b/gitmon/api.py index 41d3222..b740db7 100644 --- a/gitmon/api.py +++ b/gitmon/api.py @@ -8,13 +8,15 @@ from requests.packages.urllib3.util.retry import Retry class GitHubApi: - def __init__(self, headers=None, proxy=None): + def __init__(self, token=None, headers=None, proxy=None): self.base_url = 'https://api.github.com' self.session = requests.Session() retries = Retry(total=3, backoff_factor=1) self.session.mount('https://', HTTPAdapter(max_retries=retries)) + if token: + self.session.headers.update({'Authorization': f'Bearer {token}'}) if headers: self.session.headers.update(headers) if proxy: