Skip to content

Commit 25d80ce

Browse files
committed
added ability to use oauth token instead of private token
1 parent f381507 commit 25d80ce

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gitlab/__init__.py

Lines changed: 5 additions & 1 deletion
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] == '/':

0 commit comments

Comments
 (0)