Bikbokken Posted March 22, 2021 Share Posted March 22, 2021 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. 0 Quote Link to comment Share on other sites More sharing options...
Bikbokken Posted March 22, 2021 Author Share Posted March 22, 2021 I'm aware that it says i'm unauthorized, but i dont know where to give me authorisation besides the OpenID section on my WHMCS Admin site. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.