APIs & Integrations

ksudheer8739
Member

Webhook request validation in kotlin

SOLVE

can some one help me to implement signature validation for hubspot webhooks api. I created a webhook for a private app to receive property change event, and i have a new service which will accept the webhook events. I am trying to implement the validation as below

 

I am getting different signatures. 
Request body i am using: Raw Request Body: [{"eventId":1533917858,"subscriptionId":2811863,"portalId":20114015,"appId":3388772,"occurredAt":1726718100167,"subscriptionType":"object.propertyChange","attemptNumber":0,"objectId":22403328019,"objectTypeId":"0-3","propertyName":"dealstage","propertyValue":"17480144","changeSource":"CRM_UI","sourceId":"userId:65741093","isSensitive":false}]

 

Service is in development stage, so i  copied the event body from aws logs, and using it in my service

0 Upvotes
1 Accepted solution
ksudheer8739
Solution
Member

Webhook request validation in kotlin

SOLVE

here is what i am doing

 

val sourceString = clientSecret + requestBody
val digest = MessageDigest.getInstance("SHA-256")
val dataBytes = digest.digest(sourceString.toByteArray(Charsets.UTF_8))
dataBytes.joinToString("") { "%02x".format(it) } 
// the hex string i am getting is not the same i got from the webhook event

Note: I am using the latest object strucuture.

View solution in original post

0 Upvotes
1 Reply 1
ksudheer8739
Solution
Member

Webhook request validation in kotlin

SOLVE

here is what i am doing

 

val sourceString = clientSecret + requestBody
val digest = MessageDigest.getInstance("SHA-256")
val dataBytes = digest.digest(sourceString.toByteArray(Charsets.UTF_8))
dataBytes.joinToString("") { "%02x".format(it) } 
// the hex string i am getting is not the same i got from the webhook event

Note: I am using the latest object strucuture.

0 Upvotes