Reputation: 374
I am calling a b2c custom policy from my .net5 application. The code I'm using to redirect users from the application to the custom policy screen is:
var scheme = OpenIdConnectDefaults.AuthenticationScheme;
var properties = new AuthenticationProperties { RedirectUri = redirectUrl };
properties.Items["policy"] = "B2C_1A_xxxxxx;
return Challenge(properties, scheme);
I also want to pass a value across from my application to pre-populate an input on the B2C screen.
I am able to get a value from a url parameter by using OAUTH-KV:KeyValueKey
in the custom policy. Such that when I add &KeyValueKey=KeyValueValue
to the url manually, I am able to display KeyValueValue
in the relevant input.
However, am unable to update the C# code I have in the application so that I can generate the url with the parameter value included in it.
Upvotes: 0
Views: 579
Reputation: 131
You can add this query parameter to your Open Id Connect middleware in the startup. For example:
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions()
{
//..
Events = new OpenIdConnectEvents
{
OnRedirectToIdentityProvider = context =>
{
context.ProtocolMessage.SetParameter("KeyValueKey", "KeyValueValue");
return Task.FromResult(0);
}
}
//..
});
Upvotes: 3