The server wallet authentication flow is designed to be idempotent — calling authenticate() multiple times with the same identity is safe and will reuse existing credentials when possible.
How It Works
On the first call, the SDK:
- Generates or accepts an
accessKey (64-char hex string)
- Derives a public key from it
- Calls
create to register the identity with the backend
- Calls
exchange to obtain an access token
- Stores the token for future use
On subsequent calls with the same identity, the stored token is returned immediately.
Usage
userIdentity is your permanent wallet ID. Use the exact same string on every call — including after restarts and deploys. A different value creates a new wallet.
userIdentity + accessKey are a matched pair. Reusing an identity with a different access key returns 409 CONFLICT.
Parameters
Return Value
Access Key Management
The accessKey is the root secret for a server wallet identity. It is used to derive the public key that identifies the wallet on-chain.
If you lose the access key, you cannot recover the same wallet identity. Always persist it in a secure secrets manager (AWS Secrets Manager, HashiCorp Vault, GCP Secret Manager, etc.).
First run — omit accessKey, save the returned key:
Later runs — same userIdentity, provide the saved key:
Automatic Token Refresh
Authenticated API calls automatically handle expired tokens:
- A call receives a
401 Unauthorized response
- The SDK sends
POST /auth/refresh with session credentials
- If the refresh succeeds, the access token is updated and the original call is retried
- If the refresh fails, the error is thrown to the caller
No configuration is needed — this behavior is built into every authenticated method (whoami, signTransaction, exportPrivateKey, etc.).
Identity Conflicts
If you call authenticate with a userIdentity that already exists but provide a different accessKey, the backend returns a 409 CONFLICT error:
This protects against accidental identity collisions. To resolve:
- Use the original access key for this identity, or
- Choose a different
userIdentity string
Next Steps