Closed yudielcurbelo closed 4 years ago
I was able to get access to the configuration while setting up https://github.com/sounj142/HLSoft.BlazorWebAssembly.Authentication.OpenIdConnect
in Program.cs
builder.Services.AddAuthorizationCore(options => { })
.AddBlazoredOpenIdConnect(async (provider) =>
{
var options = new OpenIdConnectOptions();
var configuration = provider.GetRequiredService<IConfiguration>();
options.Authority = configuration["SpaOptions:Authority"].ToString();
options.ClientId = configuration["SpaOptions:SpaClientId"].ToString();
options.ResponseType = "token id_token";
options.Scopes.Add("openid");
options.Scopes.Add("profile");
options.Scopes.Add("email");
options.Scopes.Add(configuration["SpaOptions:Scope"].ToString());
return options;
})
;
Looks like this is also being tracked over here: https://github.com/dotnet/aspnetcore/issues/20231
Thanks @benhysell, this is indeed a dupe of the referenced issue.
I'm trying to access wwwroot/appsettings.json from Program.cs in Blazor WebAssembly 3.2.0 Preview 3.
Content of Program.cs
var configuration = builder.Services.BuildServiceProvider().GetRequiredService<IConfiguration>(); var ApiBaseAddress = configuration["ApiBaseAddress"];
Content of appsettings.json
{ "ApiBaseAddress": "https://localhost:5001/api/" }
Error No service for type 'Microsoft.Extensions.Configuration.IConfiguration' has been registered.