You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/communication-services/how-tos/call-automation/includes/secure-websocket-python.md
+26-41Lines changed: 26 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,54 +13,39 @@ ms.author: kpunjabi
13
13
14
14
## Websocket code sample
15
15
16
-
This sample code demonstrates how to configure OIDC client to validate websocket payload using JWT
16
+
This sample code demonstrates how to configure OIDC client to validate websocket payload using JWT. Install the following package:
17
+
18
+
`pip install cryptography`
17
19
18
20
```python
19
-
from quart import Quart, websocket, abort, request import jwt from jwt import PyJWKClient, InvalidTokenError
20
-
app = Quart(name)
21
-
JWKS_URL="https://acscallautomation.communication.azure.com/calling/keys"EXPECTED_ISSUER="https://acscallautomation.communication.azure.com"EXPECTED_AUDIENCE="ACS resource ID"# replace with actual audience
@app.websocket('/ws') async def ws(): try: auth_header = websocket.headers.get("Authorization") if not auth_header or not auth_header.startswith("Bearer "): await websocket.close(1008)# Policy violation return
0 commit comments