Webhook Abuse Protection Handshake Issue
Trying to subscribe to a webhook but I am getting an error about the 'WebHook-Allowed-Origin' header not being correct.
Response:
'type': 'urn:blackbaud:webhook-url-handshake-missing-origin-header',
'title': 'One or more validation errors occurred.',
'status': 400,
'detail': "Received an unexpected 'WebHook-Allowed-Origin' header value from your webhook URL when performing the CloudEvent's Abuse Protection handshake. The header must equal 'eventgrid.azure.net'. Review our Webhook API documentation to learn more. https://developer.blackbaud.com/skyapi/apis/webhook"
Code:
def cloud_events_handshake():
if env_vars['other']['hook_secret'] == request.args.get('webhookKey'):
event = from_http(request.headers, request.get_data())
if event['WebHook-Request-Origin'] == 'eventgrid.azure.net':
#resp = make_response(200)
response = Response(status=200, mimetype="application/json")
response.headers['WebHook-Allowed-Origin'] = 'eventgrid.azure.net'
return response
else:
abort(403)
The header is already set to the correct value, is there something I'm missing here?
Comments
-
Hey Kevin,
I don't have much experience with Python (or Flask?). From my quick experiment with it, requests weren't being processed by my `cloud_events_handshake` function unless I explicitly set the HTTP methods that were valid for my function.
@app.route('/', methods = ['OPTIONS'])
def cloud_events_handshake():Otherwise, I was just getting a successful response (200 status code) without my code having done anything with the request – no added header or response body.
You can test your webhook's OPTIONS and POST handlers with the test requests described in our documentation. This will allow you to validate your endpoint prior to working with the Webhook API. This tutorial will also walk you through a C# implementation. We also have PHP and NodeJS samples here.
Let me know if you run into other issues.
0 -
Chris,
I was able to figure it out. Within Flask, I had two routes with the same url scheme, but figured that with one being set to accept only POST requests for web hooks and another with an OPTIONS request for the handshake, flask would route the request to each function dependent on the method used. This wasn't the case as flask apparently automatically includes the OPTIONS method in its routing so it kept defaulting to the POST route which wasn't setup to handle the abuse protection handshake.
2 -
Glad you got it figured out, Kevin! Thanks for updating the post too – might help someone else who runs into this. ?
0
Categories
- All Categories
- 6 Blackbaud Community Help
- 209 bbcon®
- 1.4K Blackbaud Altru®
- 394 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 1.1K Blackbaud CRM™ and Blackbaud Internet Solutions™
- 15 donorCentrics®
- 359 Blackbaud eTapestry®
- 2.5K Blackbaud Financial Edge NXT®
- 646 Blackbaud Grantmaking™
- 563 Blackbaud Education Management Solutions for Higher Education
- 3.2K Blackbaud Education Management Solutions for K-12 Schools
- 934 Blackbaud Luminate Online® and Blackbaud TeamRaiser®
- 84 JustGiving® from Blackbaud®
- 6.4K Blackbaud Raiser's Edge NXT®
- 3.7K SKY Developer
- 243 ResearchPoint™
- 118 Blackbaud Tuition Management™
- 165 Organizational Best Practices
- 238 The Tap (Just for Fun)
- 33 Blackbaud Community Challenges
- 28 PowerUp Challenges
- 3 (Open) Raiser's Edge NXT PowerUp Challenge: Product Update Briefing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports+
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Email Marketing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Gift Management
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Event Management
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Home Page
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Query
- 779 Community News
- 2.9K Jobs Board
- 53 Blackbaud SKY® Reporting Announcements
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)
