mirror of
https://github.com/kennethreitz/python-github3.git
synced 2026-06-05 23:10:17 +00:00
logged in workaround.
This commit is contained in:
+7
-4
@@ -19,15 +19,18 @@ class GitHub(object):
|
|||||||
rate_limit = None
|
rate_limit = None
|
||||||
rate_left = None
|
rate_left = None
|
||||||
per_page = 30
|
per_page = 30
|
||||||
|
accept = 'application/vnd.github.v3+json'
|
||||||
|
|
||||||
def __init__(self, apiurl=API_URL):
|
def __init__(self, apiurl=API_URL):
|
||||||
self.__basic_auth = None
|
self.__basic_auth = None
|
||||||
|
|
||||||
def _get(self, *path):
|
def _get(self, *path):
|
||||||
r = get(*path, auth=self.__basic_auth)
|
headers = {'Accept': self.accept}
|
||||||
|
|
||||||
rate_limit = r.headers.get('x-ratelimit-remaining', None)
|
r = get(*path, auth=self.__basic_auth, headers=headers)
|
||||||
rate_left = r.headers.get('x-ratelimit-limit', None)
|
|
||||||
|
rate_left = r.headers.get('x-ratelimit-remaining', None)
|
||||||
|
rate_limit = r.headers.get('x-ratelimit-limit', None)
|
||||||
|
|
||||||
if (rate_limit is not None) or (rate_left is not None):
|
if (rate_limit is not None) or (rate_left is not None):
|
||||||
self.rate_limit = rate_limit
|
self.rate_limit = rate_limit
|
||||||
@@ -48,7 +51,7 @@ class GitHub(object):
|
|||||||
r = self._get('')
|
r = self._get('')
|
||||||
print
|
print
|
||||||
|
|
||||||
if r.status_code == 200:
|
if r.status_code == 200 and self.__basic_auth:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user