If your front end uses a third-party SDK with a public key, anyone who opens your site can read that key. Without more protection, anyone can then call identify("someone-else") and write to that person's profile, chat history and feedback. The fix is to have your server sign the user id, and have the SDK send the signature. This guide shows the steps in order, with code in five languages. I am building JustOneCX (disclosure), so the examples use its SDK. The idea is the same in any tool that supports a signed identity.
What problem does it solve?
The public key identifies your workspace. It is meant to be public. It does not prove who the person is. So the SDK cannot tell a real signed-in user from someone typing in the browser console.
Identity verification closes that gap. After a user signs in, your server signs their user id with a secret key. The service checks the signature and ignores identify() calls without a valid one.
What is the order of steps?
The order matters. If you turn the requirement on before your site sends the signature, all your existing users count as unverified.
- Copy the secret key from Settings → Developers. It is shown in full only once.
- Store it on your server only, as
JUSTONECX_SECRET_KEY. Add the empty name to.env.example. - Sign the user id on your server after login.
- Pass the signature to the SDK in the browser and deploy.
- Turn on Require identity verification.
- Sign in on your site and check that verified sign-ins arrive.
How do you sign the user id?
Use an HMAC with SHA-256 of the user id, keyed with the secret key. The result is a hex string.
// Node.js
import { createHmac } from "node:crypto";
const userHash = createHmac("sha256", process.env.JUSTONECX_SECRET_KEY)
.update(String(user.id))
.digest("hex");
# Python
import hmac, hashlib, os
user_hash = hmac.new(
os.environ["JUSTONECX_SECRET_KEY"].encode(), str(user.id).encode(), hashlib.sha256
).hexdigest()
# Ruby
require "openssl"
user_hash = OpenSSL::HMAC.hexdigest("SHA256", ENV.fetch("JUSTONECX_SECRET_KEY"), user.id.to_s)
// PHP
$userHash = hash_hmac('sha256', (string) $user->id, getenv('JUSTONECX_SECRET_KEY'));
// Go
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"os"
)
func justonecxHash(userID string) string {
mac := hmac.New(sha256.New, []byte(os.Getenv("JUSTONECX_SECRET_KEY")))
mac.Write([]byte(userID))
return hex.EncodeToString(mac.Sum(nil))
}
How do you pass it to the SDK?
identify(user.id, { plan: user.plan }, { userHash });
Sign exactly the same string you pass to identify(). For accounts, group() takes an accountHash computed the same way.
What if it does not work?
| Symptom | Likely cause |
|---|---|
| Users show as unverified after you turned Require on | Your site does not send userHash yet, or it signs a different string than the id it passes to identify(). A number versus a string, or an email versus an id. |
| Every hash is rejected | You signed with the public key (pk_) instead of the secret key. |
| It worked, then stopped | The secret key was rotated and the server still has the old one. |
| The hash is computed in the browser | Do not. The secret key would be public. Compute it on the server. |
What about rotating the key?
Rotating the secret key invalidates every hash you issued and every server event call that still uses the old key. Your server must use the new key for both event ingest and userHash. Copy the new key right after you rotate, deploy it, then check that identify calls verify.
What happens without a valid hash?
When verification is on, a call without a valid hash returns normally but is ignored. It cannot merge into another person's profile or change their traits.
What next?
Read the full identity verification guide. If you use an AI coding assistant, ask it to set this up: it adds the server code and the .env.example entry, and never sees the secret key. You paste that into your server environment yourself.