Field
Field workers are people who use an application from a phone or tablet, without a platform user
account. They sign in on an enrolled device with a PIN (or a badge), at the platform’s /field/*
endpoints, and the platform issues a short access token bound to the device’s key. The model is in
field workers and the backend how-to in
field backend.
Your backend never sees a PIN. For each request it does two things, both in this SDK:
- Verify the access token and a per-request proof signed with the same device key
(
FieldTokenVerifier). This is offline: it needs only the platform’s public signing keys. - Administer workers, devices and policies with the control-plane API (
fieldWorkers()and its siblings).
Verify a request
Section titled “Verify a request”var verifier = FieldTokenVerifier.builder() .issuer("https://auth.example.com") // the platform base URL (the token's iss) .appCode("my-app") // tokens must be addressed to this app (aud) .build(); // jwksUrl(...) skips OIDC discovery
// Authorization: "DPoP <token>", DPoP: "<proof>", the method, and the FULL public URL you serve.switch (verifier.verify(authorization, dpop, "POST", "https://app.example.com/api/orders")) { case FieldVerification.Valid v -> handle(v.principal()); // a FieldPrincipal record case FieldVerification.Invalid i -> respond(401, i.reason()); // a FieldReason constant case FieldVerification.Unavailable u -> respond(503, "keys unavailable");}verify returns a sealed FieldVerification. Map Unavailable to 503, never to “invalid”: it means
the platform’s keys could not be fetched, which is not the caller’s fault.
The URL is the full public URL you pass in (scheme, host, path; any query is ignored). It is never
rebuilt from a Host header, because a client can set one. The verifier uses only the JDK
(java.security, java.net.http): no JOSE library and no web-framework glue. It is thread-safe.
What is checked
Section titled “What is checked”- The access token must be RS256, with header type
fc-field+jwt,token_usefield,audequal to yourappCode, and a validexp. Tokens with other algorithms (HS256,none, …) are refused. - The proof must be ES256, and its
htmandhtumust match the request, itsathmust match the token, and its key’s thumbprint must equal the token’scnf.jkt. - A PIN-change-only token (
pcr) is refused: it is valid only on the platform’s PIN endpoint. - The proof’s
iatmust be within 5 minutes of now (proofMaxAge(...)widens it for devices with bad clocks). - Nonces are not checked. If you need replay protection beyond the proof’s
iatwindow, add your own.
Builder options
Section titled “Builder options”| Method | Default | |
|---|---|---|
issuer(url), appCode(code) |
required | |
jwksUrl(url) |
OIDC discovery | Skip discovery and fetch keys from this URL. |
jwksRefreshInterval(d) |
1 hour | How long fetched keys are trusted. |
clockSkew(d) |
60 s | Tolerance for the token’s exp, nbf and iat. |
proofMaxAge(d) |
5 minutes | How far the proof’s iat may be from now, either way. |
httpClient(client) |
15 s timeout | The client for discovery and keys. |
fetcher(fn), clock(clock) |
For tests and unusual networks. |
Keys are cached and refetched at most once a minute when a token names an unknown kid, so a key
rotation is picked up without waiting for the refresh interval.
The principal
Section titled “The principal”FieldPrincipal is a record with workerId, clientId, clientIdentifier, workerCode, name,
appCode, deviceId, deviceMode, sessionId, amr, authTime, expiresAt, jkt, tokenId,
actor, test and linkedPrincipalId.
deviceModeisPERSONAL,SHAREDorUNENROLLED. ForUNENROLLED,deviceIdis empty: the token’s key is not an enrolled device.actoris non-null when someone else is signed in as the worker (a supervisor, or an admin through a console sign-in code). Itstypeisfield_workerorprincipal. Every other component is still the worker’s: record the worker as the subject of an action andactoras the operator.testmarks a test identity.linkedPrincipalIdis the platform user the worker is linked to, empty when not linked. It is for audit correlation only and grants nothing on either side.
Refusal reasons
Section titled “Refusal reasons”FieldVerification.Invalid.reason() is a constant of FieldReason; detail() is for logs, not for the
client.
| Reason | Meaning |
|---|---|
malformed |
The header is not DPoP <compact JWS>, or the token is not a JWS. |
wrong_typ, wrong_token_use, wrong_aud |
The token is not a field token for this app. |
expired, invalid_token |
Past exp, a bad signature, or a disallowed algorithm. |
pcr |
A PIN-change-only token. |
missing_proof, invalid_proof, stale_proof |
The proof is absent, malformed or signed wrongly, or its iat is outside the window. |
jkt_mismatch, htm_mismatch, htu_mismatch, ath_mismatch |
The proof does not belong to this token or this request. |
Respond to any Invalid with 401. The reasons are shared with the Go SDK and the platform’s fixtures
(api/field-fixtures), so every SDK refuses the same cases.
Administer workers, devices and policies
Section titled “Administer workers, devices and policies”The calling service account needs the platform:iam:field-* permissions and access to the client.
var worker = client.fieldWorkers().ensure(new EnsureFieldWorkerRequest() .clientId(clientId).workerCode("W001").name("Ann").appCodes(List.of("my-app")));var pin = client.fieldWorkers().resetPin(worker.getId(), null); // pin.getTemporaryPin(): shown oncevar code = client.fieldDevices().createEnrolmentCode(new CreateEnrolmentCodeRequest() .clientId(clientId).mode(CreateEnrolmentCodeRequest.ModeEnum.PERSONAL) .appCodes(List.of("my-app")).assignedWorkerId(worker.getId())); // render code.getQrPayload()client.fieldPolicies().update(clientId, p -> p.pinMinLength(8L)); // read, change, write backclient.introspectFieldToken(token); // the online check that the session is still live| Resource | Methods |
|---|---|
fieldWorkers() |
ensure, list, get, update, delete, resetPin, unlock, suspend, activate, grantApp, revokeApp, signIns, link, unlink, issueBadge, listBadges, revokeBadge, bulkIssueBadges, createSignInCode, setPhoto, getPhoto, removePhoto, listUnlockKeys, revokeUnlockKey |
fieldDevices() |
createEnrolmentCode, list, get, suspend, activate, revoke |
fieldPolicies() |
get, put, update, deletePhotos, and the static toRequest(policy) |
fieldTokens() |
introspect(token); client.introspectFieldToken(token) is a shorthand |
- A policy
putreplaces the whole policy. A member left out goes back to its default, soput(clientId, new PutFieldPolicyRequest().requireAttestation(true))also switches unlock keys off (which revokes every key of the client) and photos back on.update(clientId, change)reads the policy, applies yourConsumer<PutFieldPolicyRequest>to the request that would store it unchanged, and writes the result (two calls: someone else’s edit in between is overwritten with what was read).toRequest(policy)gives you that request to change yourself. ensuretakes an optionalworkerCode: without one the platform generates one (three letters and the client’sworkerCodeDigitsdigits, for exampleKTM482) and returns it. A request without a code makes a new worker every time, so setidempotencyKey(up to 100 characters) to make it repeatable: a repeat answers the first worker, and the SDK then retries it after a lost answer. A key with a code is refused.- Photos:
setPhoto(id, image, contentType)(JPEG, PNG or WebP; the platform decides the type from the bytes and re-encodes to 512 px and 128 px),getPhoto(id, size, ifNoneMatch)(aPhotorecord withbytes,contentType,etagandnotModified;FieldWorkersResource.THUMBorFULL),removePhoto(id), andfieldPolicies().deletePhotos(clientId)for every photo of a client. Unlock keys:listUnlockKeys(id)andrevokeUnlockKey(id, unlockKeyId), which ends the key and the sessions it signed in. See the administration guide. - There is no wrapper for the per-application policy overrides and locks
(
/api/field-policies/{clientId}/applications,/locks); use the HTTP API. - A temporary PIN, a badge secret and a sign-in code are returned once. Hand them over and do not store them.
link(id, principalId)links a worker to a platform user (422 INVALID_LINKif the user cannot be linked,409 LINK_EXISTSif another worker of the client holds the link);unlinkis idempotent. Both return the refreshed worker.bulkIssueBadges(workerIds)takes 1 to 200 workers, all or nothing.- Offline verification says the token was valid when issued;
introspectis the online check that the session has not been revoked since.
Read next
Section titled “Read next”- Field workers and the field protocol
- Enrol and sign in
- The Go equivalent: Client and auth