Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages

Help for owners

I want staff to sign in to my web app with their Microsoft 365 account

Short answer

Sign-in with Microsoft Entra needs an app registration with exact redirect addresses and a decision on who may sign in: any work account, one company, or personal accounts too. Microsoft says to validate ID tokens with a library, not by hand, and to use https redirect addresses.

  • Written for business owners
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Does this sound like your situation?

  • My staff already have Microsoft 365 and I want one login for my app.
  • A test works for me but not for colleagues or other companies.
  • The error mentions a reply or redirect address that does not match.
  • People can sign in who should not be able to.
  • Signing out of my app does not sign them out properly.

Why does this happen?

  1. The wrong audience is chosen

    Microsoft's sign-in address contains a tenant value that decides who can sign in: common allows personal and work accounts, organizations allows only work or school accounts, consumers allows only personal accounts, and a specific tenant ID or domain allows only that organization. The wrong value either locks out your staff or lets in people you did not intend.

  2. The redirect address does not match

    Microsoft states that the redirect address in the request must exactly match one registered for the app, otherwise you receive error AADSTS50011. Redirect addresses must begin with https apart from localhost, are case-sensitive, and do not support wildcards for apps that allow personal accounts.

  3. ID tokens were never enabled or checked

    Microsoft states that ID tokens are not issued by default for a registered app and must be enabled, and that web apps using them must validate them. It recommends a token validation library, not manual checks.

  4. Sign-out only clears one side

    Microsoft states that to sign a user out you must both redirect to its logout address and clear your own app's session. Doing only one leaves the user signed in.

  5. Test and live share one registration

    Microsoft advises separate app registrations for development and production, so test addresses are not exposed on the live app.

What can I do about it today?

  1. Decide who should be able to sign inOnly your company, any company, or customers with personal accounts too. Write the answer down.
  2. Find out who is your Microsoft 365 adminApp registrations are created in the Microsoft Entra admin center by an admin with enough rights.
  3. List your app's web addressesThe live address, the test address and any other place it runs. Each one needs to be registered exactly.
  4. Do not share staff passwords for testingAsk for a test account created for this purpose.
  5. Keep your current login workingAdd Microsoft sign-in beside it first, and remove the old one only after staff have tried it.

When should I bring someone in?

  • Staff can sign in but see the wrong data.
  • Several apps or customers' organizations must sign in.
  • You need roles or groups from Microsoft to decide what a person may do.

How do I handle it?

  1. Settle the audience firstI write down who may sign in and choose the tenant setting to match, with your Microsoft 365 admin.
  2. Register the app with exact addressesSeparate registrations for test and live, https addresses, and a tidy list of redirect addresses.
  3. Use a standard librarySign-in and token validation go through a maintained library, as Microsoft recommends.
  4. Match the user to your own recordsA person's Microsoft identity is linked to their account in your app by a stable identifier, not by name alone.
  5. Test with a company and an outside accountI check the allowed and the blocked case, and sign-out, before staff are switched over.

The price depends on what I find, so I quote in writing after a short discovery call. Tell me what is happening and I reply within 24 hours.

What do owners ask about this?

Do I need to pay for anything extra from Microsoft?

That depends on your Microsoft plan, which I cannot judge from here. Check with your Microsoft 365 admin before starting.

What does AADSTS50011 mean?

Microsoft states it means the reply URL in the request does not match those configured for the application. The registered addresses must be corrected or the request fixed.

Can customers outside my company sign in?

Yes, if the registration allows other organizations or personal accounts. That brings extra checks, so the audience is decided first.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Found a mistake? Tell me.

For your developer: the technical fixes

Next step

Want this off your desk?

Send me a few lines on where things stand. I reply within 24 hours.