Why HMAC verification matters
Before performing any operation (such as exchanging an authorization code for an access token), your application must verify that the request really comes from Genuka. When Genuka sends the installation callback to your application, the request includes the following parameters:hmac parameter is a cryptographic signature generated by Genuka. Your application must recompute this signature using your GENUKA_CLIENT_SECRET and compare it to the one received.
If they don’t match, you must reject the request — otherwise, your app could be impersonated.
⚠️ Important: If HMAC verification is not implemented or fails, your application will never be validated or published in the Genuka App Store.
Example: Validating HMAC
Below are robust examples to validate HMAC in different programming languages. Each example recreates the signed string exactly, computes the HMAC using your client secret and compares both values using a constant-time comparison.All examples include replay attack prevention by validating the timestamp (requests older than 5 minutes are rejected).
Example verification flow
1
Receive callback from Genuka
Genuka sends an installation callback to your app with the following parameters:
2
Validate HMAC before processing
Extract parameters and validate the HMAC before any other processing:
3
Exchange code for access token
Once HMAC is validated, proceed to exchange the
code for an access token. See the Authentication guide for details.Best Practices
- ✅ Always verify the HMAC before any other processing (e.g., before exchanging the code for a token).
- ✅ Never log or expose your
GENUKA_CLIENT_SECRET. - ✅ Use constant-time comparison (e.g.,
crypto.timingSafeEqual) to avoid timing attacks. - ✅ Immediately reject any request with an invalid HMAC and return an appropriate HTTP status (401 or 403).
- ✅ Optionally, validate the
timestampto prevent replay attacks (for example, reject requests older than 5 minutes). - ✅ Record secure logs for failed verifications (without logging secrets or HMAC values) to help debugging.
Summary
| Step | Description |
|---|---|
| 1 | Receive callback parameters (company_id, timestamp, hmac, code) |
| 2 | Recreate stringToHash = "company_id={company_id}×tamp={timestamp}" |
| 3 | Generate HMAC using GENUKA_CLIENT_SECRET |
| 4 | Compare with received hmac using constant-time comparison |
| 5 | Reject if invalid, proceed if valid |
🔒 Implementing HMAC verification is mandatory to protect your integration and validate your app for the Genuka App Store.
