Skip to content

Commit 9d39abf

Browse files
committed
Allow blank token in config
1 parent 764d3ca commit 9d39abf

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

gitlab/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,12 @@ def auth(self):
168168
def credentials_auth(self):
169169
"""Performs an authentication using email/password."""
170170
if not self.email or not self.password:
171-
raise GitlabAuthenticationError("Missing email/password")
171+
# raise GitlabAuthenticationError("Missing email/password")
172+
data = json.dumps({'email':self.http_username,
173+
'password':self.http_password})
174+
else:
175+
data = json.dumps({'email': self.email, 'password': self.password})
172176

173-
data = json.dumps({'email': self.email, 'password': self.password})
174177
r = self._raw_post('/session', data, content_type='application/json')
175178
raise_error_from_response(r, GitlabAuthenticationError, 201)
176179
self.user = CurrentUser(self, r.json())

gitlab/config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def __init__(self, gitlab_id=None, config_files=None):
5353

5454
try:
5555
self.url = self._config.get(self.gitlab_id, 'url')
56-
self.token = self._config.get(self.gitlab_id, 'private_token')
5756
except Exception:
5857
raise GitlabDataError("Impossible to get gitlab informations from "
5958
"configuration (%s)" % self.gitlab_id)
@@ -79,6 +78,12 @@ def __init__(self, gitlab_id=None, config_files=None):
7978
except Exception:
8079
pass
8180

81+
self.token = None
82+
try:
83+
self.token = self._config.get(self.gitlab_id, 'private_token')
84+
except Exception:
85+
pass
86+
8287
self.http_username = None
8388
self.http_password = None
8489
try:

0 commit comments

Comments
 (0)