mirror of
https://git.juggalol.com/agatha/gitmon.git
synced 2024-11-22 23:46:42 +00:00
Add support for access token
This commit is contained in:
parent
2e2756db07
commit
ad857ab719
@ -8,13 +8,15 @@ from requests.packages.urllib3.util.retry import Retry
|
|||||||
|
|
||||||
|
|
||||||
class GitHubApi:
|
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.base_url = 'https://api.github.com'
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
|
|
||||||
retries = Retry(total=3, backoff_factor=1)
|
retries = Retry(total=3, backoff_factor=1)
|
||||||
self.session.mount('https://', HTTPAdapter(max_retries=retries))
|
self.session.mount('https://', HTTPAdapter(max_retries=retries))
|
||||||
|
|
||||||
|
if token:
|
||||||
|
self.session.headers.update({'Authorization': f'Bearer {token}'})
|
||||||
if headers:
|
if headers:
|
||||||
self.session.headers.update(headers)
|
self.session.headers.update(headers)
|
||||||
if proxy:
|
if proxy:
|
||||||
|
Loading…
Reference in New Issue
Block a user