question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configure OidcProviderOptions using IConfiguration on Blazor Wasm

See original GitHub issue

IConfiguration can’t be used when configuring the host builder

There is no way to configure AddOidcAuthentication using the IConfiguration of blazor wasm


            var builder = WebAssemblyHostBuilder.CreateDefault(args);
            builder.RootComponents.Add<App>("app");

            builder.Services.AddBaseAddressHttpClient();
            builder.Services.AddOidcAuthentication(options =>
            {
                options.ProviderOptions.Authority = "https://demo.identityserver.io";
                options.ProviderOptions.ClientId = "interactive.public";
                options.ProviderOptions.DefaultScopes.Add("api");
                options.ProviderOptions.ResponseType = "code";
            });

Ideally we need the IConfiguration information to put this configuration values on appsettings.json or appsettings.development.json etc but right now the only way is hardcoded this parameters on the Program.cs

Further technical details

  • Blazor Wasm 3.2.0-preview3.20168.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
MichaelSprangercommented, Apr 3, 2020

I realized that I am able to access the configuration like so. I use builder.Services.AddMsalAuthentication, but I expect this to work the same with AddOidcAuthentication.

            builder.Services.AddMsalAuthentication(options =>
            {
                var configuration = builder.Services.BuildServiceProvider().GetRequiredService<IConfiguration>();
...
            });
1reaction
pranavkmcommented, Mar 30, 2020

I can look at fixing the issue @dibble-james ran in to where building the IConfigurationBuilder twice fails. Do we want to do anything specific for blazor-wasm to allow reading config without having to construct it? For instance, we could expose a FooConfigurationBuilder : IConfigurationBuilder, IConfiguration off of the host builder.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core Blazor configuration
Learn about Blazor app configuration, including app settings, authentication, and logging configuration.
Read more >
How do I access the appsettings in Blazor WebAssembly?
Configurations loaded by the Blazor WebAssembly can be accessed by injecting IConfiguration services. Using IConfiguration, the values from wwwroot/appsettings ...
Read more >
How to access and read config settings into your Blazor app
This is a quick and short tip on how to read and access the settings in appsettings.json and other custom configuration files into...
Read more >
Configuration in Blazor Client (WASM) - Developing Dane
Goal. Load a json configuration file directly from a Blazor WASM client using typical . NET Core practices for working with configuration.
Read more >
Blazor WASM Redirect UserTo Signup on Universal Login
With .NET Blazor WASM, sending a user to Universal Login is as easy as <a ... var authority = (string)Configuration["Auth0:Authority"]; var ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found