Skip to content

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:

  1. 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.
  2. Administer workers, devices and policies with the control-plane API (fieldWorkers() and its siblings).
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.

  • The access token must be RS256, with header type fc-field+jwt, token_use field, aud equal to your appCode, and a valid exp. Tokens with other algorithms (HS256, none, …) are refused.
  • The proof must be ES256, and its htm and htu must match the request, its ath must match the token, and its key’s thumbprint must equal the token’s cnf.jkt.
  • A PIN-change-only token (pcr) is refused: it is valid only on the platform’s PIN endpoint.
  • The proof’s iat must 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 iat window, add your own.
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.

FieldPrincipal is a record with workerId, clientId, clientIdentifier, workerCode, name, appCode, deviceId, deviceMode, sessionId, amr, authTime, expiresAt, jkt, tokenId, actor, test and linkedPrincipalId.

  • deviceMode is PERSONAL, SHARED or UNENROLLED. For UNENROLLED, deviceId is empty: the token’s key is not an enrolled device.
  • actor is non-null when someone else is signed in as the worker (a supervisor, or an admin through a console sign-in code). Its type is field_worker or principal. Every other component is still the worker’s: record the worker as the subject of an action and actor as the operator.
  • test marks a test identity.
  • linkedPrincipalId is the platform user the worker is linked to, empty when not linked. It is for audit correlation only and grants nothing on either side.

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.

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 once
var 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 back
client.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 put replaces the whole policy. A member left out goes back to its default, so put(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 your Consumer<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.
  • ensure takes an optional workerCode: without one the platform generates one (three letters and the client’s workerCodeDigits digits, for example KTM482) and returns it. A request without a code makes a new worker every time, so set idempotencyKey (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) (a Photo record with bytes, contentType, etag and notModified; FieldWorkersResource.THUMB or FULL), removePhoto(id), and fieldPolicies().deletePhotos(clientId) for every photo of a client. Unlock keys: listUnlockKeys(id) and revokeUnlockKey(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_LINK if the user cannot be linked, 409 LINK_EXISTS if another worker of the client holds the link); unlink is 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; introspect is the online check that the session has not been revoked since.