OAuth 2.0 for Business Central APIs: service-to-service setup without web service access keys
Service-to-service (S2S) authentication replaces the web service access key with an OAuth 2.0 client credentials flow, and it works only when both halves of the setup exist: an application registered in Microsoft Entra ID, and a matching application record inside Business Central, set to Enabled, with permission sets assigned and consent granted. A token can be issued while the Business Central half is missing or incomplete, which is why the most confusing S2S failure is a successful token request followed by a rejected API call. Build both halves, in order.
S2S suits the retail integration pattern directly: a server-to-server connection with no user interaction, where a stock service, a voucher service, or an order intake process calls Business Central APIs as itself. The Client Credentials flow is the flow documented for exactly that case. The Authorization Code flow is a different setup, for user-delegated access, named here only so the two are not confused during setup.
Why the web service access key era is over
The replacement is structural, not cosmetic. An access key ties API access to a user-style credential. S2S gives the integration its own application identity, registered in Entra ID, authorized inside Business Central through permission sets, and authenticated at run time by requesting a token with its application credentials. Access can then be scoped, reviewed, and revoked as an application, and, as the upkeep section sets out, its secret carries an expiry that has to be planned for from the first day.
Authentication for these integrations requires coordination across three surfaces: Entra ID, the Business Central Admin Center, and the Business Central environment. Most setup failures are sequencing failures across those surfaces, a step completed in one place whose counterpart was never completed in another. The checklist below is ordered to close those gaps as it goes.
Checklist part 1: register the application in Entra ID
- Register the application in Microsoft Entra ID (the Azure portal side of the setup). This registration is the integration’s identity; everything later refers back to it.
- Create the client secret for the application, and record its expiry at creation time. Client secrets can last at most 24 months, so the rotation date exists from the moment the secret does, a point the upkeep section returns to.
- Assign the Dynamics 365 Business Central application permissions the integration needs. Two permission names cover the documented cases: API.ReadWrite.All covers Business Central APIs and web services; Automation.ReadWrite.All covers Automation APIs. Choose by which surface the integration actually calls, the names are not interchangeable labels for the same access.
What success looks like at this stage: a registered application, a secret whose expiry date is written down outside the portal, and application permissions assigned that match the API surface the integration will use.
Checklist part 2: permissions and admin consent
Spec check, what API.ReadWrite.All does and does not grant. API.ReadWrite.All is the Entra-side permission that covers Business Central APIs and web services. It does not, by itself, give full data access. Data access is still managed by permissions inside Business Central. Both halves of that sentence matter: granting the Entra permission without the Business Central permission sets leaves an application that can authenticate and still read nothing it should; expecting the Entra permission alone to scope data access misunderstands where scoping lives.
Admin consent is the step that makes the Entra-side assignment effective for the application, and consent appears again on the Business Central side, in the application record, in the next part of the checklist. Treat consent as a deliberate, recorded act in both places, who granted it, and when, rather than a click absorbed into setup. An integration that fails authorization checks later will be debugged against exactly those records.
Checklist part 3: the application record inside Business Central
- Create the Microsoft Entra application record inside Business Central for the registered application. Setup has two halves, registration in the Azure portal and this record, and neither substitutes for the other.
- Set the record’s State to Enabled. A record that exists but is not enabled is the classic half-finished setup: present in a screenshot, inactive in effect.
- Assign permission sets to the application record. Assign the least-privilege sets that cover what the integration actually does, and observe the one hard prohibition: applications cannot be assigned the SUPER permission set. A design that assumes SUPER for an integration identity fails on a documented constraint, not on an administrator’s preference.
- Click Grant Consent on the application record. This is the Business Central-side consent step, distinct from the Entra-side consent in part 2.
What success looks like: an application record that is present, Enabled, carrying named permission sets that are not SUPER, with consent granted. Four properties, all checkable in under a minute, and together they are the second authorization layer that the token alone never proves.
Get the first token and make the first call
With both halves in place, the run-time proof is a token request using the client credentials flow:
- Request the token from the token endpoint: https://login.microsoftonline.com/<tenantId>/oauth2/v2.0/token, substituting the environment’s tenant ID.
- Use the .default scope: https://api.businesscentral.dynamics.com/.default, the scope documented for this flow.
- Present the application credentials, the registered application and its client secret, as the client credentials the flow is named for.
- Call the API with the returned access token, against the surface the assigned permissions cover. APIs and web services under API.ReadWrite.All, Automation APIs under Automation.ReadWrite.All.
- Plan token handling around no refresh token. S2S uses no refresh token: when a new access token is needed, request a new one with the application credentials. A run-time design that stores a refresh token and waits for it to work has imported a pattern from the delegated flow, where it does not belong.
What success looks like: a token returned from the documented endpoint for the.default scope, and an API call that the returned token authorizes. Token first, call second, in that order, because the next section is what happens when only the first half of that sentence holds.
Token works, API rejects: the two-layer diagnostic
The failure has a shape: the token request succeeds, the API call is rejected. Read it as two layers being checked in sequence. Entra ID issued the token, layer one passed. Business Central then checks its own application record and its permission sets, and layer two is where the rejection lives, because a working token can still fail at exactly that check.
Work the Business Central layer first, in this order. Is the application record present for this application? Is its State set to Enabled? Are permission sets assigned, and do they cover the data the call touches, remembering that API.ReadWrite.All does not by itself grant data access, which is managed by permissions inside Business Central? Was Grant Consent clicked on the record? Each question corresponds to a checklist step in part 3, which is the point of having done them as a checklist: the diagnostic is the checklist, re-read under failure.
Only after those four check out does the Entra layer deserve a second look, permissions assigned for the right API surface, consent granted there, and a scope in the token request that matches the documented.default scope. Reversing that order burns hours in the portal while the disabled record sits in Business Central, unchanged.
Secret rotation and least-privilege upkeep
Two constraints set at setup time govern the integration for its whole life, and both belong on a calendar, not in memory. The client secret lasts at most 24 months, so it must be updated within every two years, diarise the rotation well before the expiry recorded in part 1, with the new secret issued and the calling system updated as one operation. An integration that stops on a secret’s second birthday has not suffered an outage; it has met a deadline that was known on its first day.
Least privilege is the second upkeep item. The application’s data reach is its Business Central permission sets, reviewed as the integration’s scope changes: sets added for a flow that was later retired are access nobody uses and everybody carries. The SUPER prohibition makes the ceiling explicit, an application can never hold it, and the working rule underneath it is the same one that governed part 3: the smallest set of permissions that lets the integration do its named job, re-checked when the job changes.
Rotation date recorded, permission sets reviewed, consent on record in both places. That is the upkeep state an S2S integration should be able to show on any given day, because the alternative is discovering all three during the next token-works, API-rejects incident.
, Dex Carter, Tech Writer
Keep readingNext: Business Central APIs and web services for retail data: which route to use →