File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
python-flask-directory-sync-example Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 11import os
2- from flask import (Flask , render_template , url_for )
2+ from flask import (Flask , render_template , request , Response )
33import workos
4+ from workos import client as workos_client
45
56DEBUG = False
67app = Flask (__name__ )
@@ -15,12 +16,28 @@ def home():
1516
1617@app .route ('/users' )
1718def directory_users ():
18- users = workos . client .directory_sync .list_users (directory = directory_id )
19+ users = workos_client .directory_sync .list_users (directory = directory_id )
1920 return render_template ('users.html' , users = users )
2021
2122
2223@app .route ('/groups' )
2324def directory_groups ():
24- groups = workos . client .directory_sync .list_groups (directory = directory_id )
25+ groups = workos_client .directory_sync .list_groups (directory = directory_id )
2526
2627 return render_template ('groups.html' , groups = groups )
28+
29+ @app .route ('/webhooks' , methods = ['POST' ])
30+ def webhooks ():
31+ payload = request .get_data ()
32+ sig_header = request .headers ['WorkOS-Signature' ]
33+
34+ response = workos_client .webhooks .verify_event (
35+ payload = payload ,
36+ sig_header = sig_header ,
37+ secret = os .getenv ('WEBHOOKS_SECRET' )
38+ )
39+ # Validate the response is successful
40+ print (response )
41+
42+ # Return a 200 to prevent retries based on validation
43+ return Response (status = 200 )
Original file line number Diff line number Diff line change 11
22Flask >= 1.1.2
33workos >= 0.3.2
4+ python-dotenv
You can’t perform that action at this time.
0 commit comments