From 9d39abfab32a789cec47a82f89d0496ce228b3e0 Mon Sep 17 00:00:00 2001 From: Vincent De Smet Date: Mon, 21 Nov 2016 14:53:04 +0800 Subject: [PATCH] Allow blank token in config --- gitlab/__init__.py | 7 +++++-- gitlab/config.py | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 3a1262968..680eb64e1 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -168,9 +168,12 @@ def auth(self): def credentials_auth(self): """Performs an authentication using email/password.""" if not self.email or not self.password: - raise GitlabAuthenticationError("Missing email/password") + # raise GitlabAuthenticationError("Missing email/password") + data = json.dumps({'email':self.http_username, + 'password':self.http_password}) + else: + data = json.dumps({'email': self.email, 'password': self.password}) - data = json.dumps({'email': self.email, 'password': self.password}) r = self._raw_post('/session', data, content_type='application/json') raise_error_from_response(r, GitlabAuthenticationError, 201) self.user = CurrentUser(self, r.json()) diff --git a/gitlab/config.py b/gitlab/config.py index 3ef2efb03..5dd0be51b 100644 --- a/gitlab/config.py +++ b/gitlab/config.py @@ -53,7 +53,6 @@ def __init__(self, gitlab_id=None, config_files=None): try: self.url = self._config.get(self.gitlab_id, 'url') - self.token = self._config.get(self.gitlab_id, 'private_token') except Exception: raise GitlabDataError("Impossible to get gitlab informations from " "configuration (%s)" % self.gitlab_id) @@ -79,6 +78,12 @@ def __init__(self, gitlab_id=None, config_files=None): except Exception: pass + self.token = None + try: + self.token = self._config.get(self.gitlab_id, 'private_token') + except Exception: + pass + self.http_username = None self.http_password = None try: