Skip to content

Commit a2e8cf9

Browse files
committed
Merge upstream develop changes
2 parents 3ba906c + c78f78b commit a2e8cf9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

gitlab/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class Gitlab(object):
1414
"""Gitlab class"""
1515

16-
def __init__(self, host, token="", verify_ssl=True):
16+
def __init__(self, host, token="", oauth_token="", verify_ssl=True):
1717
"""on init we setup the token used for all the api calls and all the urls
1818
1919
:param host: host of gitlab
@@ -22,6 +22,10 @@ def __init__(self, host, token="", verify_ssl=True):
2222
if token != "":
2323
self.token = token
2424
self.headers = {"PRIVATE-TOKEN": self.token}
25+
if oauth_token != "":
26+
self.oauth_token = oauth_token
27+
self.headers = {"Authorization": 'Bearer {}'.format(
28+
self.oauth_token)}
2529
if not host:
2630
raise ValueError("host argument may not be empty")
2731
if host[-1] == '/':
@@ -1405,7 +1409,7 @@ def getrawfile(self, project_id, sha1, filepath):
14051409
params=data, verify=self.verify_ssl,
14061410
headers=self.headers)
14071411
if request.status_code == 200:
1408-
return request.content.decode("utf-8")
1412+
return request.content
14091413
else:
14101414
return False
14111415

@@ -1419,7 +1423,7 @@ def getrawblob(self, project_id, sha1):
14191423
request = requests.get("{0}/{1}/repository/raw_blobs/{2}".format(self.projects_url, project_id, sha1),
14201424
verify=self.verify_ssl, headers=self.headers)
14211425
if request.status_code == 200:
1422-
return request.content.decode("utf-8")
1426+
return request.content
14231427
else:
14241428
return False
14251429

0 commit comments

Comments
 (0)