I have problem with get token when log in with Azure Active Directory using msal.js.
Maybe I'll describe you how the app works in several situations.
I. Automatic login with Active Directory Authentication is disabled. Callback on Application Registration Portal is set to home page of the app. I used the code from https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/devApps/VanillaJSTestApp/index_LoginPopup.html
- Enter the app without authorization
- Click on button which runs loginPopup, after log in get token.
Everything works, but I want authorization with Active Directory Authentication
II. Automatic login with Active Directory Authentication is enabled. Callback on Application Registration Portal is set to "***.auth/login/aad/callback". I used the code from https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/devApps/VanillaJSTestApp/index_LoginPopup.html
- Enter the app with authorization and log in with Active Directory Authentication
- acquireTokenSilent is sending error like "user_login_error:User login is required".
- Click on button which runs loginPopup, after log in I get error like "The reply address **** does not match the reply addresses configured for the application"
UPDATE: After set userAgentApplication.redirectUri = '****/.auth/login/aad/callback' and run loginPopup, token is delivered, but it's still double log in.
To summarize, after login with Azure I get error from acquireTokenSilent "user_login_error:User login is required".
III. I would like the app to behave as follows:
- Enter the app with authorization and log in with Active Directory Authentication
- Get token
Can I do it like this?
If you want to authenticate the user by the client using msal.js and also protect your Web API, then disable the 'App Service Authentication' in Azure. Protect your Web API using OWIN middleware instead.
This following sample shows a Web API protected by Azure AD Endpoint V2 using msal.js: https://github.com/Azure-Samples/active-directory-javascript-singlepageapp-dotnet-webapi-v2