I am working with Azure Graph API and it works well when I configure only one web platform having one redirect URL.
When I add multiple Web platforms and having multiple redirect URLs, it always redirects back to the last/latest redirect URLs.
As I have multiple urls configured, it should work with different applications hosted.
public void Configuration(IAppBuilder app) {
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
var _Configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var RedirectUri = _Configuration.GetSection("AzureAd:RedirectUri").Value;
app.UseCookieAuthentication(new CookieAuthenticationOptions());
OwinTokenAcquirerFactory factory = TokenAcquirerFactory.GetDefaultInstance<OwinTokenAcquirerFactory>();
app.AddMicrosoftIdentityWebApp(factory);
factory.Services
.Configure<ConfidentialClientApplicationOptions>(options => { options.RedirectUri = RedirectUri; })
.AddMicrosoftGraph()
.AddInMemoryTokenCaches();
factory.Build();
}
// Sign in
if (!Request.IsAuthenticated) {
var context = HttpContext.GetOwinContext();
context.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
context.Authentication.Challenge(
new AuthenticationProperties { RedirectUri = RedirectUri },
OpenIdConnectAuthenticationDefaults.AuthenticationType);
}