Skip to content

Commit fe4cdc1

Browse files
committed
chore: remove webhook validation from Getting started
1 parent feb3817 commit fe4cdc1

5 files changed

Lines changed: 6 additions & 29 deletions

File tree

examples/getting-started/conversation/send_handle_incoming_sms/.env.example

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,5 @@ SINCH_KEY_SECRET=
99
CONVERSATION_APP_ID=
1010
SINCH_CONVERSATION_REGION=
1111

12-
# Webhook secret (set when configuring the callback in Sinch dashboard)
13-
CONVERSATION_WEBHOOKS_SECRET=
14-
1512
# Server
1613
SERVER_PORT=3001

examples/getting-started/conversation/send_handle_incoming_sms/README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ see that the MO was received and processed.
3535
SINCH_CONVERSATION_REGION=
3636
```
3737

38-
- Webhook secret (the value you set when configuring the callback URL for this app).
39-
See [Conversation API callbacks](https://developers.sinch.com/docs/conversation/callbacks):
40-
```
41-
CONVERSATION_WEBHOOKS_SECRET=your_webhook_secret
42-
```
43-
4438
- Server port (optional; default 3001):
4539
```
4640
SERVER_PORT=3001
@@ -92,8 +86,7 @@ Forwarding https://abc123.ngrok-free.app -> http://localhost:3001
9286
Use the **HTTPS** URL when configuring the callback:
9387
`https://<your-ngrok-host>/ConversationEvent`
9488

95-
Configure this callback URL (and the webhook secret) in the Sinch dashboard for your Conversation API app.
96-
The webhook secret must match `CONVERSATION_WEBHOOKS_SECRET` in your `.env`.
89+
Configure this callback URL in the Sinch dashboard for your Conversation API app.
9790

9891
### Sending an SMS to your Sinch number
9992

examples/getting-started/conversation/send_handle_incoming_sms/controller.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,16 @@
33

44

55
class ConversationController:
6-
def __init__(self, sinch_client, webhooks_secret, app_id):
6+
def __init__(self, sinch_client, app_id):
77
self.sinch_client = sinch_client
8-
self.webhooks_secret = webhooks_secret
98
self.app_id = app_id
109
self.logger = self.sinch_client.configuration.logger
1110

1211
def conversation_event(self):
1312
headers = dict(request.headers)
1413
raw_body = getattr(request, "raw_body", None) or b""
1514

16-
webhooks_service = self.sinch_client.conversation.webhooks(self.webhooks_secret)
17-
18-
# Set to True to enforce signature validation (recommended in production)
19-
ensure_valid_signature = False
20-
if ensure_valid_signature:
21-
valid = webhooks_service.validate_authentication_header(
22-
headers=headers,
23-
json_payload=raw_body,
24-
)
25-
if not valid:
26-
return Response(status=401)
27-
15+
webhooks_service = self.sinch_client.conversation.webhooks()
2816
event = webhooks_service.parse_event(raw_body, headers)
2917
handle_conversation_event(
3018
event=event,

examples/getting-started/conversation/send_handle_incoming_sms/server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def load_config():
2222
config = load_config()
2323
port = int(config.get("SERVER_PORT") or "3001")
2424
app_id = config.get("CONVERSATION_APP_ID") or ""
25-
webhooks_secret = config.get("CONVERSATION_WEBHOOKS_SECRET") or ""
2625
conversation_region = (config.get("SINCH_CONVERSATION_REGION") or "").strip()
2726
if not conversation_region:
2827
raise ValueError(
@@ -40,7 +39,7 @@ def load_config():
4039
sinch_client.configuration.logger.setLevel(logging.INFO)
4140

4241
conversation_controller = ConversationController(
43-
sinch_client, webhooks_secret, app_id
42+
sinch_client, app_id
4443
)
4544

4645

sinch/domains/conversation/conversation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def __init__(self, sinch):
1414
self._sinch = sinch
1515
self.messages = Messages(self._sinch)
1616

17-
def webhooks(self, callback_secret: str) -> ConversationWebhooks:
17+
def webhooks(self, callback_secret: str = "") -> ConversationWebhooks:
1818
"""
1919
Create a Conversation API webhooks handler with the given webhook secret.
2020
21-
:param callback_secret: Secret used for webhook signature validation.
21+
:param callback_secret: Secret used for webhook signature validation (default "").
2222
:type callback_secret: str
2323
:returns: A configured webhooks handler.
2424
:rtype: ConversationWebhooks

0 commit comments

Comments
 (0)