Skip to content
Select theme

Authenticate an automation

AI agent getting started? Read Agents: start here first.

A service identity lets an automation use explicitly assigned permissions. It does not act as each visitor to your app. Install the SDK and keep its credential on your backend.

For a backend job or an internal app with deliberately shared application-level access, use a service identity.

An administrator creates the identity, grants it the project or organisation capabilities it needs, and issues a credential. A new service identity belongs to its organisation at No role, which grants no capability. Keep the issued secret in your backend’s secret store.

  1. In the intended organisation, create a service identity with openeng admin-sdk createServiceIdentity --input '{"name":"nightly import"}'.
  2. Grant only the project roles the integration needs, or change its existing organisation role for access across projects. Prefer project scope for a single-project integration.
  3. Issue a credential. The CLI has no command for it, because it leaves out every route that returns a credential. In the web app, open Admin, choose Service identities, find the identity and choose Issue credential. In code, call the Admin SDK’s issueServiceCredential with { principalId: "<principal-id>" }. Keep the returned secret in your backend’s secret store. See the CLI reference for the command forms that do exist.
  4. Verify that the identity can perform the intended work and that other operations are refused.

Credential issuance and membership grants are separate actions. Issuing a credential does not add data access. Access and permissions explains membership scope.

The backend exchanges that credential for platform access as the service identity. Keep the credential and resulting session on your backend. Your backend’s authenticated routes decide who may use this application-level access; the service identity does not represent each individual person visiting your app. Revoke credentials that are no longer needed.

Exchange the credential on the backend, then use the returned access token with the Objects client:

import {
createHttpsTransport,
createObjectsTransportClient,
serviceCredential,
toCredential,
} from "@openengio/sdk/objects";
const origin = "https://api.openeng.io";
const transport = createHttpsTransport(origin);
const session = await serviceCredential(transport, origin, {
input: {
credentialId: "credential-id",
secret: toCredential("credential-secret"),
},
});
if (!("refusal" in session) && session.replayed !== true) {
const objects = createObjectsTransportClient(transport, origin, session.result.accessToken);
const answer = await objects.readObject({
selector: { projectId: "project-1", ref: "main" },
input: { objectId: "object-1" },
});
console.log(answer);
}