angularazure-ad-msalmsal-angular

Angular with MSAL authentication - gets AADSTS50011 URI does not match the redirect URIs


I have a problem with authorization in my Angular application. It works ok, but when I enter via the main URL, but if I start from a subpage, and token expires, I get the following error:

AADSTS50011: The redirect URI 'https://xxxx/subpage' specified in the request does not match the redirect URIs configured for the application 

So it seems that the app requested a different URL it was regiretered. But I never asked for it. The config states that the return URL is the main page:

  auth: {
    clientId: '00001111-1111-43db-2222-eb595c6b4444',
    authority: null,
    redirectUri: 'https://office.app-local.com/',
    postLogoutRedirectUri: 'https://office.app-local.com/',
    navigateToLoginRequestUrl: true,
  },

How can I force Angular to tell the AD to come back to my main page?


Solution

  • The answer was quite simple, but hard to find. It turned out that one flag was set wrong:

    Changing the config to:

    navigateToLoginRequestUrl: false

    solves the issue.

    PS. And make sure redirectUri is really set to the valid Uri after deployment.