0 votes
in Education by (1.7m points)
Is there any way to add a custom parameter to identityserver auth request. I tried this way. but it will add parameters return URL, not as auth request query strings.

 Events = new OpenIdConnectEvents


        OnRedirectToIdentityProvider = context =>


            if (context.Properties.Items.ContainsKey("connection"))

                context.ProtocolMessage.SetParameter("connection", context.Properties.Items["connection"]);

            return Task.FromResult(0);



but I need to have those parameters on request URL not a parameter of return url..

JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by (1.7m points)
The request url looks like:


where, in my case ui_locales=en is my custom parameter. It's not a part of redirect_uri, just one more query parameter, separated by & signs. That works when you need to pass some data to your IdP. When you need just to keep some data during the request and get it back with authorization response, you can involve the State pre-defined parameter.

services.AddAuthentication().AddOpenIdConnect(Constants.MyIdpName, Constants.MyIdpName, options => {


options.Events = new OpenIdConnectEvents {

     OnRedirectToIdentityProvider = ctx => {

          var rcf = ctx.HttpContext.Features.Get<IRequestCultureFeature>();

              if (rcf.Provider != null) {

                    string lng = rcf.RequestCulture.Culture.TwoLetterISOLanguageName;

                    ctx.ProtocolMessage.Parameters.Add("ui_locales", lng == "nn" || lng == "nb" ? "no" : lng);


              return Task.CompletedTask;