slackapi/python-slack-events-api

Invalid request signature error

tonywang531 opened this issue · 2 comments

Description

Hello, not sure if this is the appropriate place for this question. I have been following How To Build a Slackbot in Python on Ubuntu 20.04 guide using this api but is unable to complete the final step. I have setup the slack app settings, verified the address by using port forward and I get "invalid request signature" error which I am not sure what it means since it does not refers to the app.py.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slackeventsapi version: 2.2.1
python version: 3.9.0
OS version(s): Mac OS 10.15.7

Steps to reproduce:

  1. follows the steps in the tutorial
  2. error happens in the last step

Expected result:

bot responds in the channel

Actual result:

unknown error, nothing is processed

Attachments:

127.0.0.1 - - [11/Nov/2020 11:34:08] "POST /slack/events HTTP/1.1" 500 -
Exception on /slack/events [POST]
Traceback (most recent call last):
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/slackeventsapi/server.py", line 102, in event
    self.emitter.emit('error', slack_exception)
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pyee/_base.py", line 111, in emit
    self._emit_handle_potential_error(event, args[0] if args else None)
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pyee/_base.py", line 83, in _emit_handle_potential_error
    raise error
slackeventsapi.server.SlackEventAdapterException: Invalid request signature
127.0.0.1 - - [11/Nov/2020 11:39:08] "POST /slack/events HTTP/1.1" 500 -

You need to set a valid Signing Secret when initializing SlackEventAdapter: https://github.com/slackapi/python-slack-events-api/blob/v2.2.1/example/example.py#L6-L7

Can you make sure if your app is running with a valid value? You can check the value at Settings > Basic Information > Signing Secret in the Slack app configuration page. It may be a bit confusing but you cannot use Client Secret for it. The expected one here is the Signing Secret.

You need to set a valid Signing Secret when initializing SlackEventAdapter: https://github.com/slackapi/python-slack-events-api/blob/v2.2.1/example/example.py#L6-L7

Can you make sure if your app is running with a valid value? You can check the value at Settings > Basic Information > Signing Secret in the Slack app configuration page. It may be a bit confusing but you cannot use Client Secret for it. The expected one here is the Signing Secret.

Thanks for the detailed pointer. Yes I did use Signing Secret but I messed up when writing to the system environment variable so it had some extra spaces. After I fixed the value it is working.