HI!
I've tried integrating WHMCS with my blazor project.
My Startup.cs is the following:
namespace ClientSite
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
services.AddServerSideBlazor();
services.AddSingleton<WeatherForecastService>();
IdentityModelEventSource.ShowPII = true;
services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies")
.AddOpenIdConnect("oidc", options =>
{
options.Authority = "https://domain/oauth/openid-configuration.php";
options.ClientId = "xxxxxxxxxxxx"; // 75 seconds
options.ClientSecret = "xxxxxxxxxxxxxxxx";
options.TokenValidationParameters = new TokenValidationParameters
{
IssuerSigningKeyResolver = (token, securityToken, kid, parameters) =>
{
var client = new HttpClient();
var response = client.GetAsync("https://domain/oauth/certs.php").Result;
var responseString = response.Content.ReadAsStringAsync().Result;
var keys = JsonConvert.DeserializeObject<JwkListcs>(responseString);
return keys.Keys;
},
ValidIssuers = new List<string>
{
"https://domain/"
}
};
options.ResponseType = "code";
options.SaveTokens = true;
options.Configuration = new OpenIdConnectConfiguration
{
AuthorizationEndpoint = "https://domain/oauth/authorize.php",
JwksUri = "https://domain/oauth/certs.php",
TokenEndpoint = "https://domain/oauth/token.php",
UserInfoEndpoint = "https://domain/oauth/userinfo.php",
Issuer = "https://domain",
};
options.GetClaimsFromUserInfoEndpoint = true;
options.Events = new OpenIdConnectEvents
{
OnAccessDenied = context =>
{
context.HandleResponse();
context.Response.Redirect("/");
return Task.CompletedTask;
}
};
});
services.AddSingleton<BlazorServerAuthStateCache>();
services.AddScoped<AuthenticationStateProvider, BlazorServerAuthState>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthentication();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});
}
}
}
But after logging in and being redirected back to my page, i get this error. (attached image)
Does anyone know the solution to this problem?
Thanks in advance.
- Bikbokken.