DecaneDocs
VerificationVerifying tokens
Verification

Verifying tokens

Decane access tokens are ES256 JWTs. Verification checks the signature and expiry and, when app_id is set, that the token’s project_id matches. It needs only a public key, which the client gets one of two ways.

Static verification key

Recommended for backends. Pass your project’s ES256 public key (SPKI PEM, from the dashboard) and every check runs locally. A key that is not a P-256 public key fails at construction with DecaneConfigError, not on the first request.

python
decane = DecaneClient(app_id=APP_ID, verification_key=os.environ["DECANE_VERIFICATION_KEY"])

JWKS

Omit the key and the client verifies against the key set Decane publishes at /.well-known/jwks.json. It is fetched on first use, cached for ten minutes, and refetched once (with a 30-second cooldown) when a token’s signature matches no held key, so a key rotation needs no redeploy.

python
decane = DecaneClient(app_id=APP_ID)

Fail-closed checks

safe_verify_access_token returns None instead of raising for a token that cannot be trusted:

python
claims = decane.safe_verify_access_token(token)
if claims is None:
    return JSONResponse({"error": "unauthorized"}, status_code=401)
i

A JWKS that cannot be fetched is not a bad token. It raises DecaneApiError with code NETWORK_ERROR, even from the safe variant, so an outage answers 500 rather than 401.

Standalone function

A drop-in for @privy-io/node’s verifyAccessToken. A client is cached per configuration, so calling it per request does not refetch the JWKS.

python
from decane import verify_access_token

claims = verify_access_token(token, app_id=os.environ["DECANE_APP_ID"])

Verification is stateless

It checks signature, expiry and project, not Decane’s revocation list. A token revoked with revoke_access_token still verifies until it expires; backend calls such as get_addresses do honour revocation at once. For immediate sign-out on a sensitive route, make one of those calls as well.