microsoftbotframework icon indicating copy to clipboard operation
microsoftbotframework copied to clipboard

KeyError: 'HTTP_AUTHORIZATION'

Open masyanru opened this issue 8 years ago • 1 comments

Hello, Tested locally, but in the Bot framework channel emulator I see only 500 error in post requests.

127.0.0.1 - - [09/Aug/2017 19:48:49] "POST /api/messages HTTP/1.1" 500 - [2017-08-09 19:48:49,332] ERROR in app: Exception on /api/messages [POST] Traceback (most recent call last): File "/Users/a.mosyagin/.virtualenvs/hybrid_env/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app response = self.full_dispatch_request() File "/Users/a.mosyagin/.virtualenvs/hybrid_env/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/a.mosyagin/.virtualenvs/hybrid_env/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/a.mosyagin/.virtualenvs/hybrid_env/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise raise value File "/Users/a.mosyagin/.virtualenvs/hybrid_env/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "/Users/a.mosyagin/.virtualenvs/hybrid_env/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request return self.view_functionsrule.endpoint File "/Users/a.mosyagin/.virtualenvs/hybrid_env/lib/python3.6/site-packages/microsoftbotframework/msbot.py", line 77, in _message_post valid_token = self._verify_token(request) File "/Users/a.mosyagin/.virtualenvs/hybrid_env/lib/python3.6/site-packages/microsoftbotframework/msbot.py", line 110, in _verify_token authorization_header = request.headers['Authorization'] File "/Users/a.mosyagin/.virtualenvs/hybrid_env/lib/python3.6/site-packages/werkzeug/datastructures.py", line 1349, in getitem return unicodify_header_value(self.environ['HTTP' + key]) KeyError: 'HTTP_AUTHORIZATION' 127.0.0.1 - - [09/Aug/2017 19:48:49] "POST /api/messages HTTP/1.1" 500 -

What do you think? Thx for answer.

masyanru avatar Aug 09 '17 16:08 masyanru

Hi Anton,

When using the simulator you need to disable the JWT validation. You can do this by setting the config value verify_jwt_signature. The simplest way to pass it as a argument to the MsBot object.

bot = MsBot(verify_jwt_signature=False)

You can also set it in the environment vars (best option) or config.yaml file.

I am going to leave this issue open as I am going to add a check to see if the emulator is been used and only give a warning if the auth validation fails or isn't present. The other option is to implement the full emulator JWT validation.

mbrown1508 avatar Aug 10 '17 04:08 mbrown1508