mirror of
https://github.com/kennethreitz-archive/github2.git
synced 2026-06-05 15:40:19 +00:00
Merge branch 'ebroder/anonymous-connections'
This commit is contained in:
@@ -44,6 +44,10 @@ Creating a request
|
||||
>>> from github2.client import Github
|
||||
>>> github = Github(username="ask", api_token=".......")
|
||||
|
||||
Or for an unauthenticated connection
|
||||
|
||||
>>> github = Github()
|
||||
|
||||
Users
|
||||
=====
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ from github2.commits import Commits
|
||||
|
||||
class Github(object):
|
||||
|
||||
def __init__(self, username, api_token, debug=False):
|
||||
def __init__(self, username=None, api_token=None, debug=False):
|
||||
self.debug = debug
|
||||
self.request = GithubRequest(username=username, api_token=api_token,
|
||||
debug=self.debug)
|
||||
|
||||
+6
-3
@@ -24,7 +24,7 @@ class GithubRequest(object):
|
||||
"https": httplib.HTTPSConnection,
|
||||
}
|
||||
|
||||
def __init__(self, username, api_token, url_prefix=None, debug=False):
|
||||
def __init__(self, username=None, api_token=None, url_prefix=None, debug=False):
|
||||
self.username = username
|
||||
self.api_token = api_token
|
||||
self.url_prefix = url_prefix
|
||||
@@ -37,8 +37,11 @@ class GithubRequest(object):
|
||||
}
|
||||
|
||||
def encode_authentication_data(self, extra_post_data):
|
||||
post_data = {"login": self.username,
|
||||
"token": self.api_token}
|
||||
if self.username and self.api_token:
|
||||
post_data = {"login": self.username,
|
||||
"token": self.api_token}
|
||||
else:
|
||||
post_data = {}
|
||||
post_data.update(extra_post_data)
|
||||
return urlencode(post_data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user