I was able to solve this myself by copying the implementation of RedirectToIdentityProvider from GitHub , and swapping the Context.ProtocolMessage.RedirectUri to my own redirect uri like so:
app.AddMicrosoftIdentityWebApp(owinTokenAcquirerFactory,
updateOptions: options =>
{
options.RedirectUri = _redirectUri;
options.PostLogoutRedirectUri = _redirectUri;
options.Notifications = options.Notifications ?? new OpenIdConnectAuthenticationNotifications();
options.Notifications.RedirectToIdentityProvider = context =>
{
var loginHint = context.ProtocolMessage.GetParameter(OpenIdConnectParameterNames.LoginHint);
if (!string.IsNullOrWhiteSpace(loginHint))
{
context.ProtocolMessage.LoginHint = loginHint;
context.ProtocolMessage.SetParameter("x-anchormailbox", $"upn:{loginHint}");
// delete the login_hint from the Properties when we are done otherwise
// it will take up extra space in the cookie.
context.ProtocolMessage.Parameters.Remove(OpenIdConnectParameterNames.LoginHint);
}
var domainHint = context.ProtocolMessage.GetParameter(OpenIdConnectParameterNames.DomainHint);
if (!string.IsNullOrWhiteSpace(domainHint))
{
context.ProtocolMessage.DomainHint = domainHint;
// delete the domain_hint from the Properties when we are done otherwise
// it will take up extra space in the cookie.
context.ProtocolMessage.Parameters.Remove(OpenIdConnectParameterNames.DomainHint);
}
context.ProtocolMessage.SetParameter(ClaimConstants.ClientInfo, "1");
context.ProtocolMessage.SetParameter("x-client-brkrver", IdHelper.CreateTelemetryInfo());
if (context.ProtocolMessage.IssuerAddress != null && context.ProtocolMessage.IssuerAddress.EndsWith("/authorize", StringComparison.OrdinalIgnoreCase))
{
context.ProtocolMessage.RedirectUri = _redirectUri;
}
return Task.CompletedTask;
};
});