WFM Terminal can hand a worker to the phone Clock app using a short-lived, single-use code. The QR URL contains the code instead of a long-lived portal session key. Deploy the updated Portals package and portal runtime together before enabling this integration in WFM Terminal.
The global class is b3p.PortalLoginCode. Its global static method returns a String:
global static String issue(Id contactId, Integer ttlSeconds)
After authenticating the worker at the kiosk, WFM Terminal calls:
String code = b3p.PortalLoginCode.issue(contactId, 120);
Use the returned code in this URL:
https://<your-site-domain>/b3p__Portal?loginCode=<code>#MobileApp
Preserve any existing query parameters and route when adding loginCode. Do not include sessionKey. Issuance is available to trusted Apex callers across namespaces, not as a public remoting action. The kiosk must establish the worker's identity before calling it. Convert issuance exceptions to the terminal's normal ErrorResponse.
A null TTL defaults to 120 seconds, values above 600 are capped at 600, and zero or negative values are rejected. Missing, nonexistent, non-Contact and portal-disabled Contact IDs are rejected. Malformed IDs are rejected by Apex's Id type. Treat the code as a credential: put it only in the QR URL and do not log it.
Call b3p.GlobalRemotingRouter.callObject with controller b3p.Portal and the following JSON parameters:
{"endp":"redeemLoginCode","code":"<code>"}
The REST fallback uses POST to the site's /services/apexrest/b3p/GlobalRemotingRouter/ endpoint with this body:
{"controllerName":"b3p.Portal","endp":"redeemLoginCode","code":"<code>"}
Both routes return the same response envelope. The existing REST router JSON-encodes the envelope as a string; the portal transport decodes it.
{"statusCode":200,"statusType":"OK","success":true,"responseObject":{"sessionKey":"<session-key>"}}
Every redemption failure returns success: false, statusCode 400, and the localized Portal_InvalidSession label as message. Wrong, expired, used and disabled-user codes receive the same error. The contact's portal-disabled flag is checked again at redemption. Only one redemption of a code succeeds. The resulting session uses the existing portal session policy.
The portal removes loginCode from the address bar before making the request, retaining other query parameters and #MobileApp. Redemption completes before session bootstrap and stores the returned session through the normal sign-in path. A failed redemption clears any previous phone identity and opens normal sign-in with a message asking the worker to scan a fresh terminal QR code. Requests are neither cached nor queued for offline replay.
b3p__Login_Code__c stores the Contact lookup, expiry and used timestamp for each code. It never stores the plain code. Keep this object private; guest object permissions are not required. Retain existing Site access to the Portal and GlobalRemotingRouter Apex entry points.
Expired and used codes are cleaned up automatically as later codes are redeemed. No Platform Cache partition or scheduled-job setup is required.