LPgenerator / mattermost_bot

MatterBot - A chat bot for MatterMost (http://www.mattermost.org).
MIT License
211 stars 60 forks source link

KeyError 'Token' #19

Closed paddatrapper closed 8 years ago

paddatrapper commented 8 years ago

I'm getting

[08/02/2016 07:31:32] Starting new HTTP connection (1): mattermost.domain.com
[08/02/2016 07:31:32] Starting new HTTPS connection (1): mattermost.domain.com
Traceback (most recent call last):
  File "/usr/local/bin/matterbot", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/mattermost_bot/cli.py", line 17, in main
    b = bot.Bot()
  File "/usr/local/lib/python2.7/dist-packages/mattermost_bot/bot.py", line 27, in __init__
    settings.SSL_VERIFY
  File "/usr/local/lib/python2.7/dist-packages/mattermost_bot/mattermost.py", line 127, in __init__
    self.login(team, email, password)
  File "/usr/local/lib/python2.7/dist-packages/mattermost_bot/mattermost.py", line 131, in login
    self.user = self.api.login(team, email, password)
  File "/usr/local/lib/python2.7/dist-packages/mattermost_bot/mattermost.py", line 45, in login
    self.token = p.headers["Token"]
  File "/usr/lib/python2.7/dist-packages/requests/structures.py", line 54, in __getitem__
    return self._store[key.lower()][1]
KeyError: 'token'

My settings are:

BOT_URL = 'http://mattermost.domain.com/api/v3'
BOT_TEAM = 'dev'

I have tried the suggestions in #2 and #16, and tried other version values, but this has not helped.

I'm running mattermost v3.2 on Debian stable

paddatrapper commented 8 years ago

Fixed by changing the BOT_URL to

BOT_URL = 'https://mattermost.domain.com/api/v3'
thiyagaraj commented 8 years ago

I just want to add that I had the same issue and was at a loss since none of the proposed solutions were working, I then printed out p.text and found that the error was that the bot user's email was not verified. I had enabled email verification for everyone after the bot went live and hence it was getting blocked. Just putting this in here in case it helps someone.

{"id":"api.user.login.not_verified.app_error","message":"Login failed because email address has not been verified","detailed_error":"","request_id":"xxxxxxxxxxxx","status_code":401}