slackapi / python-slack-events-api

Slack Events API adapter for Python (Flask required)
https://api.slack.com/events
MIT License
343 stars 116 forks source link

slackeventsapi.server.SlackEventAdapterException: Invalid request timestamp #94

Closed hashimjd closed 2 years ago

hashimjd commented 3 years ago

Description

Describe your issue here.

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

Requirements

Bug Report

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

Reproducible in:

slackeventsapi version: python version: OS version(s):

Steps to reproduce:

  1. Make a post request through POSTMAN to the slack_event_adapter to replicate sending a message through channel
  2. The json component of the request is given below which is sent as a "Pre-request Script".

Expected result:

The expected result was that the request would be parsed by my application and dealt accordingly.

Actual result:

I run into an error saying "slackeventsapi.server.SlackEventAdapterException: Invalid request timestamp" despite having HTTP_X_SLACK_REQUEST_TIMESTAMP configured and this is set dynamically to ensure that the timestamp is of the time when the request is sent. This is highlighted in the screenshot below.

Screen Shot 2021-05-14 at 11 42 23 AM Screen Shot 2021-05-14 at 11 43 57 AM

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

mwbrooks commented 3 years ago

Hi @hashimjd 👋🏻 Thanks for the detailed issue, including the screenshots!

It looks like the expected header is X-Slack-Request-Timestamp. In the sample above, it looks like Postman is setting HTTP_X_SLACK_REQUEST_TIMESTAMP.

Can you try updating the header to be X-Slack-Request-Timestamp? (Case sensitivity should not matter)

Please let me know how that goes! Michael

hashimjd commented 3 years ago

I tried doing that but the problem still persists. I've attached a screenshot below that demonstrates the issue. In the server section, the issue still is "slackeventsapi.server.SlackEventAdapterException: Invalid request timestamp"

Screen Shot 2021-05-17 at 9 21 52 AM
seratch commented 2 years ago

You may no longer be working on this but if you dynamically set the x-slack-request-timestamp value, the x-slack-signature value must be also updated using the timestamp value. Thus, this is an expected behavior (= this library correctly detects invalid x-slack- header values in this scenario)

I hope this helps.

github-actions[bot] commented 2 years ago

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out.

github-actions[bot] commented 2 years ago

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.