Skip to content
Visual explainer 3h to learn 5 steps

App registrations, service principals and OAuth tokens

Explain app objects and service principals, redirect URIs, OAuth 2.0 and OIDC tokens, and delegated versus app permissions.

By Invicly Tech, , in Microsoft Entra & Microsoft 365 Administration. About 12 minutes to read.

Topic 10 of 31

In short

Registering an app in Microsoft Entra ID creates an application object, the global definition of the app, in its home tenant. Each tenant that uses the app gets a service principal, the local identity that permissions, consent and sign-ins attach to. Apps then sign users in with OpenID Connect (OIDC) and call APIs with OAuth 2.0 access tokens, using either delegated permissions (acting for a user) or application permissions (acting as itself).

Think of it like this: The application object is a franchise's recipe book; each service principal is one local restaurant that follows it, with its own staff, licences and inspection records.

Explained simply

Apps need identities too. When a developer wants their app to let people sign in with a work account, or to read data from Microsoft Graph, they register the app in Microsoft Entra ID. Registering gives the app a client ID, a list of addresses it may send users back to, and a list of permissions it asks for.

Registering creates two things. The application object is the master definition, kept in the tenant where the app was registered. The service principal is a local copy in each tenant that uses the app. When a SaaS company's app is used by your staff, the company owns the application object, and your tenant holds the service principal.

Signing in and calling APIs use two standards. OpenID Connect (OIDC) signs the user in and gives the app an ID token, which says who the user is. OAuth 2.0 gives the app an access token, which it shows to an API like Graph to prove it is allowed to call it.

Permissions come in two kinds. Delegated permissions let the app act for a signed-in user, and it can never do more than that user can. Application permissions let the app act alone, with no user, often across the whole tenant. Because application permissions are powerful, only an admin can approve them. This approval is called consent.

Press Play on a diagram to walk through it one step at a time.

CompareApplication object versus service principal
Application object
  • One per app, in its home tenant
  • Found under App registrations
  • Holds redirect URIs, credentials, permissions requested
  • Identified by the application (client) ID
Service principal
  • One per tenant that uses the app
  • Found under Enterprise applications
  • Holds consent grants, assignments, sign-in logs
  • Has its own object ID
SequenceAuthorization code flow with OIDC
User browser
Web app
Entra ID
API
  1. 1Redirect to Entra with client ID and scopes
    Web app to User browser: Redirect to Entra with client ID and scopes
  2. 2User signs in and consents
    User browser to Entra ID: User signs in and consents
  3. 3Redirect to registered URI with a code
    Entra ID to User browser: Redirect to registered URI with a code
  4. 4Deliver code
    User browser to Web app: Deliver code
  5. 5Exchange code plus app credential
    Web app to Entra ID: Exchange code plus app credential
  6. 6ID token, access token, refresh token
    Entra ID to Web app: ID token, access token, refresh token
  7. 7Call API with access token
    Web app to API: Call API with access token
MapWhere each app setting lives
An app in Entra ID
  • App registrations (application object)
    • Redirect URIs and platforms
    • Certificates and secrets
    • API permissions requested
    • Expose an API and app roles
  • Enterprise applications (service principal)
    • Users and groups assigned
    • Permissions consented
    • Single sign-on and provisioning
    • Sign-in and audit logs

In depth

Three IDs that are easy to mix up

A registered app has an application (client) ID, which is the same in every tenant and is what the app sends when it signs in. The application object also has its own object ID, used when you edit the registration through Graph, for example with Update-MgApplication. Each service principal has another object ID, used for consent grants, app role assignments and Enterprise applications settings.

Scripts fail in confusing ways when these are swapped. A good habit is to name variables clearly, such as appId, appObjectId and spObjectId, and print all three after creating an app. Sign-in logs show the client ID as Application ID, so that is the one to search for when tracing a sign-in.

  • Client ID (appId): same everywhere, used at sign-in
  • App object ID: edits the registration
  • Service principal object ID: consent, roles, assignments
  • Sign-in logs show the client ID

Redirect URIs and platforms

A redirect URI is where Entra sends the browser after sign-in, carrying an authorization code or token. Entra compares it exactly with the list on the registration, so a missing trailing slash or a different port causes error AADSTS50011, which says the redirect URI does not match.

You add redirect URIs per platform. Web is for server-side apps that can keep a credential. Single-page application is for browser apps using the authorization code flow with PKCE. Mobile and desktop is for public clients that cannot keep a secret. Redirect URIs must use HTTPS, with an exception for http://localhost during development. Remove localhost and test URIs before an app goes to production, and never add wildcard-like catch-all addresses.

What is inside the tokens

Tokens from Entra are JSON Web Tokens (JWTs): three base64url parts, a header, a payload of claims, and a signature. Paste a test token into a decoder such as jwt.ms to read it; never paste production tokens into tools you do not control.

In an ID token, aud is the client app's ID, and claims like name, preferred_username, oid (the user's object ID) and tid (the tenant) describe the user. In an access token, aud is the API, for example Microsoft Graph, and scp lists delegated scopes or roles lists application permissions. Access tokens usually last between 60 and 90 minutes; the app uses a refresh token to get a new one. APIs must check signature, issuer, audience and expiry before trusting any claim.

CompareID token versus access token
ID token (OIDC)
  • For the client app
  • aud = the app's client ID
  • Says who signed in
  • Never sent to an API
Access token (OAuth 2.0)
  • For the resource API
  • aud = the API
  • scp or roles = what is allowed
  • Sent as a Bearer header

Delegated versus application permissions, and consent

Delegated permissions are the intersection of what the app was granted and what the user can do. If an app has Mail.Read delegated, it reads only the signed-in user's mailbox. Application permissions have no user: Mail.Read as an application permission reads every mailbox in the tenant unless you limit it further with Exchange Online RBAC for applications.

Consent records that the permission was approved. Users may consent to some low-risk delegated permissions, depending on your user consent settings. Admin consent is required for all application permissions and for higher-impact delegated ones. Turn on the admin consent workflow so users can request an app instead of being stuck, and review grants regularly under the app's Permissions tab in Enterprise applications.

  • Delegated: app plus user, limited by the user
  • Application: app alone, tenant-wide by default
  • Admin consent required for all application permissions
  • Restrict user consent; enable the admin consent workflow

Learn it in 5 short steps

About 35m each. Track them with a timer in your plan.

  1. 1
    Compare application and service principal objects~35m
  2. 2
    Set redirect URIs~35m
  3. 3
    Read ID and access tokens~35m
  4. 4
    Compare delegated and app permissions~35m
  5. 5
    Grant consent~35m

Key points

  • An app registration creates one application object; every tenant using it gets its own service principal.
  • Redirect URIs must exactly match what the app sends; Entra only returns codes and tokens to registered URIs.
  • The ID token tells the app who signed in (OIDC); the access token lets it call an API (OAuth 2.0).
  • Delegated permissions appear as scp in the token; application permissions appear as roles.
  • Application permissions and high-impact delegated permissions need admin consent.

Key terms

Tap a card to flip it. 0/6 known

Examples

powershell
Connect-MgGraph -Scopes "Application.ReadWrite.All"
$app = New-MgApplication -DisplayName "Contoso Expenses (lab)" `
  -SignInAudience "AzureADMyOrg" `
  -Web @{ RedirectUris = @("https://localhost:5001/signin-oidc") }
$sp = New-MgServicePrincipal -AppId $app.AppId
"AppId (client ID): $($app.AppId)"
"App object ID:     $($app.Id)"
"SP object ID:      $($sp.Id)"

Register a single-tenant web app and create its service principal; note the three different IDs.

Fixing a redirect URI mismatch

A developer at Fabrikam runs their app on https://localhost:5001 and sees AADSTS50011. Step 1: the error shows the redirect URI the app sent: https://localhost:5001/signin-oidc. Step 2: the registration lists https://localhost:5000/signin-oidc under Web. Step 3: add the correct URI under the same platform and save. Evidence: the next sign-in returns to the app and the sign-in log shows success for that Application ID. Cleanup: remove the old URI if no one uses it, and remove localhost entries before production.

powershell
Connect-MgGraph -Scopes "Application.ReadWrite.All"
$app = Get-MgApplication -Filter "appId eq '<client-id>'"
$app.Web.RedirectUris
Update-MgApplication -ApplicationId $app.Id -Web @{
  RedirectUris = @("https://localhost:5001/signin-oidc")
}

Reading delegated and application tokens

Two synthetic access tokens for Microsoft Graph, decoded. The first has scp with User.Read Mail.Read and an oid for a user: a delegated token, so the app sees only that user's mail. The second has roles with Mail.Read and no scp: an application token, so it can read every mailbox. Step 1: check aud is Graph in both. Step 2: look for scp or roles. Step 3: in Enterprise applications, open each app's Permissions tab to confirm who granted the consent and when.

text
// delegated (payload, trimmed)
{ "aud": "https://graph.microsoft.com", "tid": "<tenant-id>",
  "oid": "<user-object-id>", "scp": "User.Read Mail.Read" }

// application (payload, trimmed)
{ "aud": "https://graph.microsoft.com", "tid": "<tenant-id>",
  "oid": "<sp-object-id>", "roles": ["Mail.Read"] }

Quick reference

  • Application object: one per app, home tenant; service principal: one per tenant that uses it
  • Client ID = appId; it is the same in every tenant
  • AADSTS50011 = redirect URI does not match the registration
  • ID token aud = client app; access token aud = the API
  • scp claim = delegated permissions; roles claim = application permissions
  • Application permissions always need admin consent
  • Create a service principal from a registration: New-MgServicePrincipal -AppId

Common mistakes

  • Mixing up the application object ID with the client ID or the service principal object ID in scripts.
  • Granting an application permission such as User.ReadWrite.All when a delegated scope or a narrower permission would do.
  • Sending an ID token to an API; APIs must accept only access tokens issued for their own audience.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1Your tenant uses a SaaS app published by another company. What does your tenant contain?

Question 2

2An app needs to read every user's calendar overnight with no one signed in. Which permission type fits?

Question 3

3Which claim in a Graph access token lists delegated permissions?

Question 4

4A user sees AADSTS50011 after signing in. What is the most likely fix?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    In a lab tenant, find one app under App registrations and its matching entry under Enterprise applications. Write down its client ID and both object IDs.

  2. Exercise 2medium

    Register a single-tenant web app with a localhost redirect URI, add the delegated User.Read permission for Graph, and grant consent. Then clean up.

  3. Exercise 3hard

    List every service principal in your tenant that holds an application permission on Microsoft Graph, with the permission names, so you can review them.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Do I need an app registration for every SaaS app?
Not usually. Gallery SaaS apps are added as enterprise applications, which creates a service principal for the publisher's app. You register an app yourself when you build it or need a custom integration.
Is OAuth 2.0 the same as OpenID Connect?
No. OAuth 2.0 is about authorization: getting access tokens to call APIs. OpenID Connect is a layer on top that adds sign-in and the ID token.
What does single-tenant versus multitenant mean?
A single-tenant app accepts sign-ins only from its home tenant. A multitenant app can be used by other Entra tenants, each of which gets its own service principal after consent.
Can I see who consented to an app?
Yes. The app's Permissions tab in Enterprise applications shows admin and user consent, and the audit logs record each Consent to application event with the actor.

Go deeper

ShareXLinkedInWhatsApp