0
votes

I would like to know reason why Azure Active Directory login page is not shown when i run my webapi locally. I need to always deploy webapi to azure, to see AAD Login page to see WEBAPI is AAD enable. Just like WebSite, is there way in WEB API to enable Login page while running api app locally.

I already configured with AAD Auth in startup.cs of webapi project below is the code.

            app.UseWindowsAzureActiveDirectoryBearerAuthentication(
            new WindowsAzureActiveDirectoryBearerAuthenticationOptions
            {
                Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
                TokenValidationParameters = new TokenValidationParameters
                {
                    ValidAudience = ConfigurationManager.AppSettings["ida:Audience"]
                },
            });

Is there any other setting that needs to be applied for locahost Azure AD with login page available while debugging locally

1
Are you following any particular MSDN code sample for your app?juvchan

1 Answers

3
votes

When using OAuth2, there should not be any difference in terms of authentication whether the API is hosted locally, on the public internet or anywhere else. The token acquisition phase remains the same regardless of the ultimate recipient of the resulting token. However, that said: the middleware added via UseWindowsAzureActiveDirectoryBearerAuthentication should NOT result in any in-browser authentication experience. If you observe such a page when you deploy to Azure, you are likely triggering that behavior through other settings (such as EasyAuth, perhaps?). For a detailed description of the difference between web API and web page authentication patterns, please see this post.