Create Client Assertion
Create a fresh ES256 JWT for each token request. The local browser generator supports Sandbox only. Use the language-specific backend examples below for your backend integration.
Local browser tool
An ES256 client_assertion appears automatically after you enter both values for Sandbox. Copy signs a fresh JWT for the next token request. This tool fixes aud to https://test.tomopayment.com/v1/oauth2/token. Use the backend signing examples for your application.
Open the QuickStart generator →
The key and assertion remain in page memory. They are not sent to the documentation server or written to browser storage, URLs, logs, or failure reports. Clear removes the inputs and output from this page; it does not clear a value you already copied to the clipboard.
Accepts the Console BEGIN SECRET KEY wrapper, raw base64url private EC P-256 JWK, private JWK JSON, and unencrypted PKCS#8 BEGIN PRIVATE KEY. Public keys, RSA keys, and other curves are not supported.
Backend signing
Dependencies: Node.js 22; built-in node:crypto · TypeScript: npm install --save-dev typescript@5.8.2 @types/node@22.13.10. Library documentation
import { createPrivateKey, randomUUID, sign } from 'node:crypto';
export function createClientAssertion(
clientId: string,
secretKey: string,
tokenEndpoint: string,
): string {
// 1. Read the private P-256 JWK from your Console Secret Key.
const privateJwkBytes = Buffer.from(secretKey, 'base64url');
const privateJwkJson = privateJwkBytes.toString('utf8');
const privateJwk = JSON.parse(privateJwkJson);
if (
privateJwk.kty !== 'EC' ||
privateJwk.crv !== 'P-256' ||
!privateJwk.d
) {
throw new Error('The Console Secret Key must contain a private P-256 JWK.');
}
const privateKey = createPrivateKey({
key: privateJwk,
format: 'jwk',
});
// 2. Identify this client and create a fresh, short-lived assertion.
const assertionLifetimeSeconds = 300;
const issuedAt = Math.floor(Date.now() / 1000);
const expiresAt = issuedAt + assertionLifetimeSeconds;
const jwtHeader = {
alg: 'ES256',
typ: 'JWT',
};
const claims = {
iss: clientId,
sub: clientId,
aud: tokenEndpoint,
iat: issuedAt,
exp: expiresAt,
jti: randomUUID(),
};
// 3. Sign the header and claims using the JWT R||S signature format.
const encodedHeader = encodeJwtPart(jwtHeader);
const encodedClaims = encodeJwtPart(claims);
const signingInput = encodedHeader + '.' + encodedClaims;
const signingBytes = Buffer.from(signingInput, 'utf8');
const signatureBytes = sign('sha256', signingBytes, {
key: privateKey,
dsaEncoding: 'ieee-p1363',
});
const encodedSignature = signatureBytes.toString('base64url');
// Return the client_assertion form value to your backend caller.
return signingInput + '.' + encodedSignature;
}
function encodeJwtPart(value: object): string {
const json = JSON.stringify(value);
const bytes = Buffer.from(json, 'utf8');
return bytes.toString('base64url');
}
Read the same three environment variables on your backend, then call the function. Use the returned value as client_assertion, never the Secret Key itself.
const baseUrl = process.env.TOMO_IDV_BASE_URL;
const clientId = process.env.TOMO_CLIENT_ID;
const secretKey = process.env.TOMO_SECRET_KEY;
if (!baseUrl || !clientId || !secretKey) {
throw new Error('Set the three TOMO environment variables before signing.');
}
const tokenEndpoint = baseUrl.replace(/\/+$/, '') + '/v1/oauth2/token';
const clientAssertion = createClientAssertion(
clientId,
secretKey,
tokenEndpoint,
);
// Send clientAssertion as client_assertion in the token request.
// Keep it on your backend; do not log it.
Signing requirements
- Use the Console Secret Key for this client: base64url-encoded JSON private JWK, EC P-256. The corresponding public key must be registered for the same client ID.
- When integrating your backend, keep the Secret Key and assertion out of frontend code and logs. The local QuickStart tool processes manually supplied values only in page memory.
- JWT header: alg=ES256 and typ=JWT. Claims: iss=sub=registered client ID; aud=the exact token URL derived from TOMO_IDV_BASE_URL.
- iat and exp are integer Unix seconds. The SDK example uses exp=iat+300; this is the example lifetime, not a claim about a server maximum.
- Generate a fresh jti and signed assertion for every token request. Assertions are single-use even before exp.
- ES256 JWT signatures use the 64-byte R||S form. Node requests ieee-p1363; the JOSE libraries handle that format.