Authentication & tokens
dropin never sees a password or an OAuth flow: your backend is the identity provider. It
signs a short-lived HS256 JWT locally with your tenant’s api_secret — zero network
calls to dropin to mint one — and hands that token to the client. apiSecret must never
reach the browser; only @dropinnodex/server (Node-only) can use it.
Mint a user token (server only)
Section titled “Mint a user token (server only)”// server-only — never bundle this into a browser buildimport { DropInServer } from '@dropinnodex/server'
const server = new DropInServer({ tenantId: process.env.DROPIN_TENANT_ID!, apiKey: process.env.DROPIN_API_KEY!, apiSecret: process.env.DROPIN_SIGNING_SECRET!, url: 'https://api.getnodex.cloud',})
// Inside your own token endpoint, after you've authenticated the caller yourself:const token = await server.createUserToken(userId, { expiresIn: '1h' }) // max 24hexpiresIn accepts "30s", "15m", "1h", "1d"-style strings and is capped at 24
hours — a longer value throws before a token the gateway would reject is even minted.
There’s no client- or react-side equivalent: minting requires apiSecret, which only
ever lives on your server.
Construct a client with a tokenProvider
Section titled “Construct a client with a tokenProvider”The client (and the React provider wrapping it) never holds apiSecret — only a
tokenProvider callback that fetches a token from your own backend endpoint.
tokenProvider is called once on init and again on a 401, not per request (spec §9).
import { DropInClient } from '@dropinnodex/client'
const client = new DropInClient({ url: 'https://api.getnodex.cloud', apiKey: process.env.NEXT_PUBLIC_DROPIN_API_KEY!, tokenProvider: async () => { const res = await fetch('/api/token') const { token } = await res.json() return token },})import { DropInProvider } from '@dropinnodex/react'
function Providers({ children, userId }: { children: React.ReactNode; userId: string }) { return ( <DropInProvider url={process.env.NEXT_PUBLIC_DROPIN_API_URL!} apiKey={process.env.NEXT_PUBLIC_DROPIN_API_KEY!} userId={userId} // who the tokenProvider mints for tokenProvider={async () => { const res = await fetch('/api/token') return (await res.json()).token as string }} > {children} </DropInProvider> )}DropInProvider also accepts an already-constructed client directly:
<DropInProvider client={myClient}> — useful if you need to build the DropInClient
yourself (e.g. to share it outside React).
Revoke a user’s tokens
Section titled “Revoke a user’s tokens”Tokens are signed offline, so there is nothing to “delete” — a token stays valid until it expires. Revocation is how you cut one short: it is recorded server-side and enforced from the next request onward, so a token already sitting in a browser stops working immediately.
await server.revokeUserTokens(userId)Call this on logout, on a ban, or when an account is compromised. It invalidates all of that user’s outstanding tokens, not one specific token.
This is also why the 24h TTL ceiling is an upper bound rather than a recommendation: short tokens shrink the window in which a leaked one is useful, and revocation covers the rest.
Related
Section titled “Related”- Limits — token TTL ceiling and the per-tenant rate limits every authenticated request charges.
- Data security — what we store, where, and why we never hold your users’ credentials.
- Server SDK reference — every option on
DropInServer, generated from the typings.