Registering a Microsoft Entra ID application for app-only access
This guide is part of the Publicus connection catalog. Once you have the credentials, connect the service and Publicus stores them for you.
Distilled from Microsoft’s own documentation: OAuth 2.0 client credentials flow, Get access without a user, Quickstart: Register an application, Add credentials, RBAC for Applications in Exchange Online. Retrieved 2026-08-26.
App-only access runs with the application’s own identity, with no signed-in user: use it for unattended work — polling a shared mailbox, writing to a team calendar, a nightly export — where the delegated flow’s requirement that someone sign in and stay consented does not fit. The permissions are application permissions, they are consented once by a tenant administrator, and they apply tenant-wide unless you scope them (step 6).
-
Sign in to the Microsoft Entra admin center as at least an Application Developer, and switch to the target tenant via the Settings icon if you have access to several.
-
Browse to Entra ID → App registrations → New registration, name the application, and under Supported account types choose Accounts in this organizational directory only. App-only access is always against one named directory, so the multitenant and personal-account options buy nothing here. No redirect URI is needed.
-
Select Register, then record the Application (client) ID and the Directory (tenant) ID from the Overview page. The tenant ID goes in the connection’s Tenant field — as a GUID or a domain name such as
contoso.onmicrosoft.com.common,organizationsandconsumersare not valid for this flow. -
Under Certificates & secrets → Client secrets → New client secret: add a description, choose an expiration (maximum 24 months; Microsoft recommends under 12), select Add, then immediately copy the secret Value — it is never shown again.
-
Under API permissions → Add a permission → Microsoft Graph → Application permissions, add the permissions the connected services need (e.g.
Mail.Read,Mail.Send,Calendars.ReadWrite), then Add permissions. Application permissions always require administrator consent: select Grant admin consent for <tenant>, confirm, then refresh and verify “Granted for <tenant>” appears under Status. If you are not an administrator of the tenant, send one the admin-consent URL instead:https://login.microsoftonline.com/{tenant}/adminconsent?client_id={client_id}&state={state}&redirect_uri={redirect_uri}. -
Scope mailbox and calendar access. A consented
Mail.Readreaches every mailbox in the tenant, andMail.Sendcan send as any user. To narrow that, use RBAC for Applications in Exchange Online — it replaces the legacy Application Access Policies and supports up to 10,000 apps per organization. Connected to Exchange Online PowerShell as a member of Organization Management:Terminal window New-ServicePrincipal -AppId <application (client) ID> -ObjectId <service principal object ID> -DisplayName "Publicus connection"New-ManagementScope -Name "Shared mailboxes" -RecipientRestrictionFilter "CustomAttribute1 -eq 'publicus'"New-ManagementRoleAssignment -App <service principal object ID> -Role "Application Mail.Read" -CustomResourceScope "Shared mailboxes"Test-ServicePrincipalAuthorization -Identity <application (client) ID> -Resource <target mailbox>Take the two IDs from Enterprise applications, not from App registrations — that page shows different values.
Operational notes:
- Grants from the two systems are a union. A resource-scoped RBAC assignment narrows nothing while the same permission also sits consented tenant-wide in Entra ID. Remove the unscoped grant from API permissions once the scoped assignment is in place, or the app keeps its organization-wide reach.
- There is no refresh token. The grant never issues one. The client secret is the durable credential — when the access token expires (~1 hour) a new one is minted from the same client id and secret, and when the secret expires the connection stops working until it is rotated. Diary the expiry you chose in step 4.
/medoes not work. There is no signed-in user to resolve it against; address mailboxes explicitly, as/users/{id|userPrincipalName}/messages. For the same reason this auth system publishes no verification probe: every app-only read requires some application permission, so a fixed probe would answer 403 for a correctly configured least-privilege app — indistinguishable from a rejected credential.- One resource per token. The request carries
https://graph.microsoft.com/.default, which asks for everything already consented on this app registration for Graph — and only for Graph. Adding a permission in the portal takes effect only after an administrator consents again. - Certificates instead of a secret. Microsoft recommends certificate credentials over shared secrets, and a tenant can forbid client secrets outright through application management policies. This descriptor covers the shared-secret form of the grant only; where that policy is enforced, the app must present a certificate or federated credential instead, which is a different auth system.
- Cached permissions. Exchange caches an app’s permissions for between 30 minutes and 2 hours, so a permission change may not take effect immediately.
Test-ServicePrincipalAuthorizationbypasses the cache.
Connect it to Publicus
Section titled “Connect it to Publicus”Open Connections under Credentials, choose Microsoft, and pick Microsoft Entra ID — app-only (no user). Publicus asks for exactly the fields listed above and keeps them in your workspace’s secret storage.
See also: Microsoft in the catalog.
This guide is maintained by Publicus and published under CC BY 4.0.