Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

ASP.NET 3.1 : Dynamic Updating OpenID Connect Options

$
0
0

I am having ASP.NEt 3.1 Application adn I am trying to update my OpenIDConnection options Below is the code I am trying to use I am getting error as Client ID Parameter must be provided

public class Startup
{
    private readonly IConfiguration _appConfiguration;
    private IApplicationBuilder _appBuilder;
    public Startup(IConfiguration configuration)
    {
      _appConfiguration = configuration;
    }

    public void ConfigureServices(IServiceCollection services)
    {
      services.AddAuthentication()
      .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme)
      .AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, "Scheme1", options =>
      {
        //Wan to Set Client Id, Authority and Client Secret Dynamically
      });
      services.AddSingleton<OpenIdUpdater>();
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime lifetime)
    {
      _appBuilder = app;
      app.UseAuthentication();
      app.UseStaticFiles();
      app.UseRouting();
      app.UseEndpoints(builder => builder.MapControllers());
    }
}

  public class OpenIdUpdater
  {
    private readonly IOptionsMonitor<OpenIdConnectOptions> _openIdConnectOptionsMonitor;
    public OpenIdUpdater(IOptionsMonitor<OpenIdConnectOptions> openIdConnectOptionsMonitor)
    {
      _openIdConnectOptionsMonitor = openIdConnectOptionsMonitor;
	  var opt = _openIdConnectOptionsMonitor.CurrentValue;
        opt.CLientID = "....";
        );
    }
  }

Here the problem is I am getting values of client Id after Configure Services. In Configure services values are null and I want to update them later once I get the values.


Viewing all articles
Browse latest Browse all 9386

Trending Articles