SoloDB Documentation Help

Configure Entra API access

Use this workflow to let a Microsoft Entra application read SoloDB actions for a signed-in user. The middle tier obtains an Entra access token for the SoloDB API through On-Behalf-Of (OBO). SoloDB accepts that access token directly on the action read endpoints, or the middle tier can exchange it at /oauth/entra for a SoloDB bearer token. The first permission is Action.Read.Own; access to other users' actions requires Action.Read.All and a SoloDB administrator account for delegated access. Unattended integrations can instead use an Entra service principal with an administrator-consented application role, as described below.

All SoloDB integration settings and credentials belong in database records under Admin → OAuth2. No tenant IDs, client IDs, secrets or signing keys need to be added to PHP host configuration.

Delegated Entra tokens can also use the domain permissions described in the API scope catalogue. Expose the required scopes on the SoloDB resource registration, add them to the service and client allow lists, and request them explicitly. Direct bearer authentication discovers all scope-enabled REST listeners. Application-only access remains restricted to the cross-user action endpoints described below.

Configure unattended application access

Use client credentials when no user should sign in. The integration obtains an application access token from Entra and uses it directly on the cross-user action endpoints, or exchanges it at /oauth/entra first. The service principal does not impersonate a user and requires no linked oneLab user or administrator account.

  1. On the SoloDB API resource registration B, create an enabled App role with value Action.Read.All and Allowed member types: Applications. This role is separate from the delegated scope with the same value.

  2. On B, set api.requestedAccessTokenVersion to 2 and add the optional access-token claim idtyp. Merge these settings into the existing manifest without removing existing settings or optional claims:

    { "api": { "requestedAccessTokenVersion": 2 }, "optionalClaims": { "accessToken": [{ "name": "idtyp", "essential": false, "additionalProperties": [] }] } }

    Application authorization requires idtyp: app, no scp claim, and a roles array containing Action.Read.All. The signature, issuer, tenant, GUID audience, principal object ID, lifetime and allowed caller azp are also checked. ID tokens, delegated tokens presented as applications and role-less application tokens are rejected. See Microsoft's claim-validation guidance and app-role configuration.

  3. Create a separate integration registration A with a secret, certificate or federated credential. Under API permissions → My APIs → B → Application permissions, select Action.Read.All and grant administrator consent. No interactive redirect URI, delegated Graph permission or OBO assertion is needed for this flow.

  4. In Admin → OAuth2 → Scopes, create a non-default supported scope Action.Read.All. Under Services, configure a Microsoft resource service B with the tenant GUID and B's application client ID. Enable Entra exchange, set Allowed Entra caller client IDs to A's application client ID, and Allowed Entra API scopes to Action.Read.All. The resource service needs no secret or redirect URL for validating tokens.

  5. To keep the exchange flow available, create a dedicated local Client, select B's resource service and the Action.Read.All scope, and set its grant types to urn:ietf:params:oauth:grant-type:token-exchange. Retain its generated client ID, secret and RS256 signing key. These are local credentials, distinct from A's Entra credentials.

  6. Obtain the Entra token server-side. With a secret, submit these form-urlencoded fields:

    POST https://login.microsoftonline.com/TENANT_ID/oauth2/v2.0/token Content-Type: application/x-www-form-urlencoded grant_type=client_credentials&client_id=INTEGRATION_APP_CLIENT_ID&client_secret=URL_ENCODED_SECRET&scope=api%3A%2F%2FSOLODB_API_CLIENT_ID%2F.default

    The requested scope is B's Application ID URI followed by /.default, never a delegated Action.Read.Own scope. See Microsoft's client credentials reference.

  7. To call oneLab directly, send the Entra access token as the bearer token:

    GET https://SOLODB_HOST/api/list/action?status=open&page=1&page_size=30 Authorization: Bearer ENTRA_APPLICATION_ACCESS_TOKEN Accept: application/json

    Direct access uses B's Microsoft service, its enabled Entra exchange setting, the caller ID allow list and allowed scopes. No local SoloDB client ID or secret is needed for this path. The token is checked on every request and is limited to the same action read endpoints. An application token can use only the two cross-user endpoints.

  8. Alternatively, exchange the returned access token using the local client:

    { "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange", "client_id": "SOLODB_CLIENT_ID", "client_secret": "SOLODB_CLIENT_SECRET", "subject_token": "ENTRA_APPLICATION_ACCESS_TOKEN", "subject_token_type": "urn:ietf:params:oauth:token-type:access_token", "scope": "Action.Read.All" }

    POST this JSON to https://SOLODB_HOST/oauth/entra. Explicitly request Action.Read.All: omitting scope still defaults to Action.Read.Own and is refused for applications. The role, service allow list and local client scope must all grant Action.Read.All. The local token has a subject spn:TENANT_ID:SERVICE_PRINCIPAL_OBJECT_ID, application principal metadata and no associated local user. Its lifetime is bounded by the source token and at most one hour; no refresh token is issued. No schema migration is required for application tokens.

  9. Use the returned oneLab bearer token with either GET /api/user/actions/{user_principal_name} for a selected user's open actions, or GET /api/list/action?status=open&page=1&page_size=30. Follow pagination for the latter endpoint.

Action.Read.All permits reads of all users' actions in this oneLab instance. The selected UPN is a target selector, not proof of delegated authority. Application tokens are accepted only on these two cross-user action endpoints for GET/HEAD. /api/me/actions, /api/user/me, writes, unrelated APIs and browser sessions are unavailable to them. Removing the caller, scope, service binding or exchange grant, or disabling exchange, blocks subsequent calls with already issued local tokens. Entra role/consent revocation is evaluated on new Entra issuance; existing tokens may last until their short expiry. Keep assertions and credentials out of logs.

On the service page, Test permissions accepts either delegated or application tokens and reports permissions shared by the token, service and each linked local client. The TypeScript demo supports YOURAPP_ENTRA_MODE=client_credentials and runs once without starting an HTTP server. See its README for environment settings.

Understand the delegated token flow

There are three application roles: the frontend, the middle-tier API (A), and the SoloDB API resource (B). Each uses an Entra registration. A server-rendered application may combine the frontend and middle-tier responsibilities.

SoloDBMiddle tier AEntraFrontendSoloDBMiddle tier AEntraFrontendUserSign inRequest access to AToken A, audience ARequest with Token AOBO using Token A and A credentialsToken B, audience B, delegated action scopePOST /oauth/entra with Token B and SoloDB client credentialsScoped SoloDB access tokenGET /api/user/me and /api/me/actions with SoloDB tokenCurrent user and assigned actionsUser

Microsoft issues the OBO token; SoloDB performs a separate token exchange. A passes only token B to SoloDB. This keeps each token with its intended resource. Microsoft describes the audience and delegation rules in its OBO protocol reference.

A Microsoft browser session helps the frontend acquire a token silently through MSAL. It does not authenticate an HTTP API request by itself. If silent acquisition requires interaction or consent, redirect the user through sign-in. Use delegated access tokens for this user flow; ID tokens and Graph tokens are rejected. App-only tokens use the separate application authorization rules above. See MSAL token acquisition.

Identify the registrations and credentials

Replace these placeholders with the complete values copied from Entra and SoloDB:

Value

Meaning

Where it is used

TENANT_ID

Directory tenant GUID

Both Microsoft OAuth2 Service records

MIDDLE_TIER_CLIENT_ID

Application ID of A

OBO authentication; allowed caller list on B

MIDDLE_TIER_SECRET

Secret belonging to A

A's Microsoft OAuth2 Service record

SOLODB_API_CLIENT_ID

Application ID of B

Resource Service client ID; validated v2 token audience

api://SOLODB_API_CLIENT_ID/Action.Read.Own

Exposed delegated permission on B

Entra OBO scope request

SOLODB_CLIENT_ID and SOLODB_CLIENT_SECRET

Credentials generated by SoloDB

Local token exchange authentication

The IDs in the initial example are abbreviated and cannot be entered literally. The client ID and the ID in the scope URI also differ. If that difference reflects two registrations, establish which is A and which is B. If both were meant to identify B, correct them from the portal. A secret belongs to its issuing registration; it cannot authenticate a different client. Rotate the secret included in the original setup notes before production use.

Register the SoloDB API in Entra

On registration B, select the intended tenant account type and set the Application ID URI, normally api://SOLODB_API_CLIENT_ID. Under Expose an API, add the delegated scope Action.Read.Own and enable it. Choose the consent policy appropriate to the organization. Reserve Action.Read.All for Admins only consent. See Expose a web API.

Set api.requestedAccessTokenVersion to 2 in B's Microsoft Graph application manifest. The resource controls the access-token version. Using the v2 token endpoint alone does not select a v2 access token. This implementation supports the public Microsoft cloud and tenant-specific v2 tokens. See Access token versions.

B requires no secret or redirect URI for token validation. If B also supplies SoloDB's interactive Microsoft login, configure that login separately with its secret, delegated Graph User.Read permission and exact callback URL https://solodb.example/oauth2/callback.html.

Configure the middle tier in Entra

On registration A, expose a delegated permission for the frontend to call A, for example access_as_user. Grant the frontend permission to that API. Then add B's Action.Read.Own under A's API permissions → My APIs → Delegated permissions, and arrange consent before making OBO requests. Add a secret or certificate for A's confidential-client authentication. OBO depends on a user token whose audience is A, as described in Microsoft's OBO flow.

The frontend requests A's scope through MSAL. A validates that incoming token for its own tenant, audience and permission before requesting B's token. A server-rendered app that receives an authorization code rather than a user access token can acquire B's token through its authorization-code flow; it need not manufacture an OBO assertion.

For an external middle tier, keep A's credentials in its protected credential store. If the middle tier runs inside this PHP project, store A's credentials in a Microsoft OAuth2 Service record and retrieve that record through Admin\Service\oAuth2Service::findServiceById(). The provided Api\OAuth\EntraOnBehalfOfClient::acquireToken($middleTierService, $validatedTokenA, $fullScope) helper reads the credentials from the record. Call it only after A has validated token A. For Conditional Access challenges, use MSAL's claims-challenge handling in the middle tier; the PHP helper reports a refused OBO request without returning provider error details.

Clear the application's module configuration cache through the normal deployment procedure and restart the web processes so the new route and listener are discovered. The web process must be able to write data/cache, which holds cached Microsoft public signing keys, and reach login.microsoftonline.com over HTTPS. Signing keys are refreshed on rollover and cached for up to one hour; an unknown key can trigger a refresh at most once per minute per tenant.

Configure SoloDB database records

  1. Under Admin → OAuth2 → Scopes, create the value Action.Read.Own, with type supported. Turn Is default off. Use short scope names here; the full api://... URI belongs in Entra token requests.

  2. Under Admin → OAuth2 → Services, create or edit a Microsoft service representing B. Enter the complete TENANT_ID and SOLODB_API_CLIENT_ID, and select the local Action.Read.Own scope. Enable Entra token exchange. A service used only for exchange can leave Client secret and Redirect URL blank; it does not sign users in.

  3. Set Allowed Entra caller client IDs to MIDDLE_TIER_CLIENT_ID. Multiple IDs are separated by spaces. This checks B's signed azp claim, identifying the application that obtained the token.

  4. Set Allowed Entra API scopes to Action.Read.Own.

  5. Under Admin → OAuth2 → Clients, create a dedicated client for the middle tier. Select the Action.Read.Own scope, set Grant types to urn:ietf:params:oauth:grant-type:token-exchange, and select the Microsoft OAuth2 service. Copy the generated client ID and secret. The client receives an RS256 signing key stored in the database. A redirect URL is not used by this exchange; if the client form requires one, use the middle tier's real HTTPS URL.

  6. On the service view, review the setup checks. Test service secret requests a client credentials token when this service has a secret. Test local client secret verifies the SoloDB secret without displaying it. Test permissions validates a delegated Entra access token and shows the effective scopes for linked local clients.

  7. Link each intended user through an active Microsoft OAuth2 Authentication method in the same tenant. A successful existing Microsoft sign-in stores the user's Microsoft object ID. The exchange matches that ID and the tenant of the user's Authentication service. An administrator can correct an existing user's Authentication association if provisioning left it attached to another method.

The exchange does not create users or match them by email, username or a supplied user ID. Each user must already be active and linked to a Microsoft Authentication method in the trusted tenant, and pass that method's allowed-domain check. See Microsoft's claim validation guidance.

The Microsoft service used for a user's login may differ from resource Service B. They must belong to the same tenant. Keep B's exchange settings separate from Graph login scopes so that enabling delegated API access does not change existing sign-in behavior.

Obtain and exchange a token

A sends the following form to Entra after validating token A. Values must be URL-encoded:

POST https://login.microsoftonline.com/TENANT_ID/oauth2/v2.0/token Content-Type: application/x-www-form-urlencoded client_id = MIDDLE_TIER_CLIENT_ID & client_secret = MIDDLE_TIER_SECRET & grant_type = urn:ietf:params:oauth:grant-type:jwt-bearer & requested_token_use = on_behalf_of & assertion = TOKEN_A & scope = api://SOLODB_API_CLIENT_ID/Action.Read.Own

The returned Entra access_token can be sent directly in Authorization: Bearer to GET /api/me/actions or GET /api/user/me. A delegated Action.Read.All token from a linked SoloDB administrator can also call the two cross-user action endpoints directly. SoloDB checks the signed Entra token, the configured caller and service scopes, and the linked user on each request. To use the local exchange instead, send the Entra token as the subject token and use SoloDB's own client credentials here:

POST https://SOLODB_HOST/oauth/entra Content-Type: application/json Accept: application/json { "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange", "client_id": "SOLODB_CLIENT_ID", "client_secret": "SOLODB_CLIENT_SECRET", "subject_token": "TOKEN_B", "subject_token_type": "urn:ietf:params:oauth:token-type:access_token", "scope": "Action.Read.Own" }

The endpoint also accepts form-urlencoded fields. Send token B in the request body; the Authorization header is for SoloDB API bearer tokens. The local exchange follows the access-token request and response vocabulary of RFC 8693. The local client selects its configured OAuth2 service. Actor tokens, alternate audiences and resource indicators are not supported.

Successful response:

{ "access_token": "ONE_LAB_TOKEN", "issued_token_type": "urn:ietf:params:oauth:token-type:access_token", "token_type": "Bearer", "expires_in": 600, "scope": "Action.Read.Own" }

The expiry shown is an example. The local lifetime is bounded by the remaining lifetime of token B, the existing SoloDB access-token lifetime and a maximum of one hour. There is no local refresh token. Obtain a new Entra token and exchange it again when necessary. The legacy /oauth/refresh endpoint refuses these scoped tokens.

Call the action APIs

GET https://SOLODB_HOST/api/me/actions?status=open&page=1&page_size=30 Authorization: Bearer ONE_LAB_TOKEN Accept: application/json

/api/me/actions identifies the user from the validated local token. It ignores supplied usernames or user IDs when selecting ownership. Without status, it returns open and closed actions. Supported statuses are all, open and closed; the response is a paginated HAL collection with _embedded.items, page, page_size, page_count and total_items. Follow pagination to retrieve every action. The default page size is 30, with a maximum of 1000.

Permission

Endpoints

Additional requirement

Action.Read.Own

GET /api/user/me, GET /api/me/actions

Active linked user

Action.Read.All

Own endpoint, GET /api/user/actions/{user_principal_name}, GET /api/list/action

SoloDB administrator

Tokens carrying only action permissions are restricted to these read endpoints. They cannot access unrelated APIs, mutate actions or establish a browser session. Existing clients calling the two cross-user endpoints must now request Action.Read.All; openid or User.Read alone no longer authorizes those endpoints.

Enable Action.Read.All later

Create and consent to the delegated Action.Read.All permission on B, with Admins only consent, then add it to A's API permissions. In SoloDB, create a non-default supported scope Action.Read.All. Create another scope record containing Action.Read.Own Action.Read.All, keep it non-default, and assign it to the dedicated client. Add Action.Read.All to B's Service allowed-scope list. The user must be a SoloDB administrator before the exchange will issue a token carrying this scope.

The granted local scopes must be present in all four places: the requested local scope, B's signed scp claim, the Service allowed-scope list and the selected SoloDB client's scope. The exchange defaults to Action.Read.Own if scope is omitted; it never silently adds Action.Read.All.

Validate and maintain the integration

Test with two linked users who have different actions. Each Own token should return only its user's records, including closed records when requested. Confirm that an Own token receives 403 on both cross-user endpoints and unrelated APIs. Confirm that an All token succeeds for an administrator and is refused for an ordinary user.

Check that invalid signatures, wrong tenant or audience, unauthorized caller apps, missing delegated scopes, expired tokens and unlinked or inactive users are rejected. Use a staging Entra tenant and the target SoloDB host for the final end-to-end test.

Result

Likely cause

400 invalid_request

Missing fields, incorrect token type, malformed JSON or unsupported exchange parameters

401 invalid_client

Wrong local secret/client, missing exchange grant, disabled Service or wrong Service binding

400 invalid_grant

Invalid Entra token or missing active tenant/object-ID user link

400 invalid_scope

Scope missing from one of the allow lists, or All requested by a non-administrator

403 insufficient_scope on API calls

Token cannot access that endpoint, or user no longer has the required role

503 temporarily_unavailable

Microsoft signing keys cannot be retrieved, or the SoloDB signing key is missing

Disabling B's Service, removing its allowed caller, removing a granted scope or deactivating the user blocks subsequent API calls using already issued Entra-exchange tokens. Keep audit logs free of assertions, tokens and secrets. Rotate A's secret through the OAuth2 Service Update client secret action when the middle tier uses the SoloDB database record. Entra consent revocation is evaluated on new Entra token issuance; local tokens remain valid until their short expiry unless a local policy check blocks them.

29 October 2026