Webhook Validation
Hey, I am validating my user.create webhook as per the webhooks guide, checking the id and timestamp against the
api/v1/events/{event_id}
endpoint, but I am getting a 403
status code response. I am using the content of the webhook (the encoded JWT) as my token for the validation. Am I doing something wrong?
5 Replies
I am validating the JWT against my open-id config as I would with any other JWT and so is there a need to validate webhook again (see below):
Thanks for providing all the details.
It looks like you are encountering a 403 status code, which indicates that the credentials provided are invalid. Are you able to double the following items?
Invalid Access Token: Ensure that the access token you are using is valid and has not expired. The token should be a valid bearer token with the necessary permissions to access the /api/v1/events/{event_id} endpoint.
Incorrect Token Usage: The token used for the Authorization header should be a valid access token obtained through the proper authentication flow, not the encoded JWT from the webhook payload. The JWT from the webhook payload is used to verify the authenticity of the webhook request, not for API authentication.
Scope and Permissions: Verify that the access token has the correct scopes and permissions to access the event details. You might need to check the permissions associated with the token.
Here is a revised version of your method, ensuring that the access token is correctly used for the API call:
Let me know this helps you with what you are seeing
Thanks @Andre @ Kinde . That explains things a bit more.
The flow I am trying to achieve is: user registers -> triggers webhook -> backend receives webhook payload and adds user to database -> returns 200 status code. As it is the webhook triggering my custom endpoint and not a user, there is not a token being passed in. As a user is registering and they don't have an access token yet, what token do I use to hit that
events
endpoint? I assume it could be an admin token?You would need to create a M2M application and use a token from this to pass to the endpoint
Ah cool, thanks. That clarifies things
Hey @Daniel_Kinde, so I implemented the suggestion above. I tried using my m2m token with
read:events
enabled as a permission, and I get a 403 response. I am setting the token as a bearer token
Authorization header value.
I then tried giving my m2m app all the scopes available and I still get a 403
. Any suggestions as to what's up with that?
See below for implementation 😃