Skip to content

Commit 89da40c

Browse files
authored
fix(py): Clean up webhook snippets (#4864)
1 parent 3da509d commit 89da40c

File tree

1 file changed

+35
-31
lines changed
  • src/docs/product/integrations/integration-platform

1 file changed

+35
-31
lines changed

src/docs/product/integrations/integration-platform/webhooks.mdx

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,22 @@ function verifySignature(request, secret = "") {
5151
```
5252

5353
```python
54-
body = json.dumps(request.body)
55-
expected = hmac.new(
56-
key=client_secret.encode('utf-8'),
57-
msg=body,
58-
digestmod=sha256,
59-
).hexdigest()
60-
61-
if expected != request.headers['Sentry-Hook-Signature']:
62-
raise UnauthorizedError
54+
import hashlib
55+
import hmac
56+
import json
57+
58+
expected_digest = request.headers['sentry-hook-signature']
59+
body = json.dumps(request.body)
60+
61+
digest = hmac.new(
62+
key=client_secret.encode('utf-8'),
63+
msg=body,
64+
digestmod=hashlib.sha256,
65+
).hexdigest()
66+
67+
68+
if digest != expected_digest:
69+
raise UnauthorizedError
6370
```
6471

6572
## Request Structure
@@ -83,31 +90,28 @@ actor
8390
: The actor is who, if anyone, triggered the webhook. If a user in Sentry triggered the action, then the actor is the user. If the Sentry App itself triggers the action, then the actor is the Application. And if the action is triggered automatically somehow within Sentry, then the actor is ‘Sentry.’
8491

8592
```python
86-
# Samples cases:
87-
88-
# user installs sentry app
89-
90-
"actor": {
91-
'type': 'user',
92-
'id': <user-id>,
93-
'name': <user-name>,
94-
}
95-
96-
# sentry app makes request assign an issue
93+
# Samples cases:
9794

98-
"actor": {
99-
'type': 'application',
100-
'id': <sentry-app-uuid>,
101-
'name': <sentry-app-name>,
102-
},
95+
# User installs sentry app
96+
"actor": {
97+
"type": "user",
98+
"id": <user-id>,
99+
"name": <user-name>,
100+
}
103101

104-
# sentry (sentry.io) auto resolves an issue
102+
# Sentry app makes request assign an issue
103+
"actor": {
104+
"type": "application",
105+
"id": <sentry-app-uuid>,
106+
"name": <sentry-app-name>,
107+
}
105108

106-
"actor": {
107-
'type': 'application',
108-
'id': 'sentry',
109-
'name': 'Sentry',
110-
},
109+
# Sentry (sentry.io) auto resolves an issue
110+
"actor": {
111+
"type": "application",
112+
"id": "sentry",
113+
"name": "Sentry",
114+
}
111115
```
112116

113117
<Note>

0 commit comments

Comments
 (0)