Skip to content

Commit

Permalink
Support for Personal Access Token in Mattermost
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaelor committed Oct 6, 2017
1 parent 05d765c commit 03266f2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Use the APIv3 branch for that.
### REQUIREMENTS
- Python >= 3.4 (3.3 should work too)
- websockets 3.2
- [mattermostdriver](https://github.com/Vaelor/python-mattermost-driver) > 0.3.0
- [mattermostdriver](https://github.com/Vaelor/python-mattermost-driver) > 2.2.0

### INSTALLATION

Expand All @@ -38,10 +38,13 @@ BOT_ADMINS = ('@yourname') # Names need the @ in front!
BOT_IDENTITY = {
# Required
'login': '[email protected]',
'password': 'botpassword',
'team': 'nameoftheteam',
'server': 'mattermost.server.com',
# For the login, either
'login': '[email protected]',
'password': 'botpassword',
# Or, if you have a personal access token
'token': 'YourPersonalAccessToken',
# Optional
'insecure': False, # Default = False. Set to true for self signed certificates
'scheme': 'https', # Default = https
Expand Down
2 changes: 1 addition & 1 deletion mattermost.plug
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Module = mattermost
[Documentation]
Description = A Mattermost backend for errbot.
Author = Christian Plümer
Version = 1.0.1
Version = 1.1.0
Website = https://github.com/Vaelor/errbot-mattermost-backend
10 changes: 7 additions & 3 deletions mattermost.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ class MattermostBackend(ErrBot):
def __init__(self, config):
super().__init__(config)
identity = config.BOT_IDENTITY
self._login = identity.get('login')
self._password = identity.get('password')
self._login = identity.get('login', None)
self._password = identity.get('password', None)
self._personal_access_token = identity.get('token', None)
self._mfa_token = identity.get('mfa_token', None)
self.team = identity.get('team')
self._scheme = identity.get('scheme', 'https')
self._port = identity.get('port', 8065)
Expand Down Expand Up @@ -378,7 +380,9 @@ def serve_once(self):
'verify': not self.insecure,
'timeout': self.timeout,
'login_id': self._login,
'password': self._password
'password': self._password,
'token': self._personal_access_token,
'mfa_token': self._mfa_token
})
self.driver.login()

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mattermostdriver>=2.1
mattermostdriver>=2.2

0 comments on commit 03266f2

Please sign in to comment.