Configure OidcProviderOptions using IConfiguration on Blazor Wasm
See original GitHub issueIConfiguration 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:
- Created 3 years ago
- Reactions:1
- Comments:12 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.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 aFooConfigurationBuilder : IConfigurationBuilder, IConfiguration
off of the host builder.