OAuth 2.0 and Custom API Pages in AL: Modern Cloud Integrations
Modern Business Central SaaS integrations use OAuth 2.0 Client Credentials (S2S) via Microsoft Entra ID paired with dedicated AL API Pages (PageType = API).
Step 1: App Registration in Microsoft Entra ID
Register an app in Entra Admin Center, add the Application permission API.ReadWrite.All under Dynamics 365 Business Central, grant admin consent, and generate a Client Secret.
Step 2: Authorize in Business Central
Open Microsoft Entra Applications (Alt + Q), paste the Client ID, set State = Enabled, and assign least-privilege Permission Sets (never SUPER).
Step 3: Dedicated Custom API Page (PageType = API)
page 50100 "BCG Custom Item API"
{
PageType = API;
APIPublisher = 'bcgnomen';
APIGroup = 'integration';
APIVersion = 'v1.0';
EntityName = 'customItem';
EntitySetName = 'customItems';
SourceTable = Item;
DelayedInsert = true;
ODataKeyFields = SystemId;
layout
{
area(Content)
{
repeater(General)
{
field(id; Rec.SystemId) { Editable = false; }
field(number; Rec."No.") { }
field(displayName; Rec.Description) { }
field(unitPrice; Rec."Unit Price") { }
field(lastModifiedDateTime; Rec.SystemModifiedAt) { Editable = false; }
}
}
}
}
Step 4: Test in Postman
Request a token from https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token with scope=https://api.businesscentral.dynamics.com/.default, then call your customItems endpoint!