using GoogleOAuth.Components;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.Google;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme;
})
.AddCookie()
.AddGoogle(options =>
{
options.ClientId = "...";
options.ClientSecret = "...";
});
builder.Services.AddAuthorization();
// Add services to the container.
builder.Services.AddRazorComponents();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();
app.UseAntiforgery();
app.MapStaticAssets();
app.MapRazorComponents();
app.Run();
Ich habe ein Beispiel -Blazor -Projekt ohne Identität erstellt und versuchte, Google hinzuzufügen, aber ich erhalte diese Ausnahme immer wieder: < /p>
AuthentifizierungFailException: Der OATH -Zustand fehlte oder ungültig. /> Dies ist alles mein Code: < /p> [b]Program.cs[/b] [code]using GoogleOAuth.Components; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Google;
// Add services to the container. builder.Services.AddRazorComponents();
var app = builder.Build();
// Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); }
Ich bin (sehr) neu in C/C++, aber ich versuche, es in Visual Studio Code (VS Code) einzurichten, wo ich Erfahrung mit der Verwendung von Python habe.
I Ich habe die beiden Erweiterungen ( Code Runner...
Ich habe eine Blazor -Serverside -Anwendung, in der ich Authentifizierung hinzufüge. Postauthentifizierung, überprüfen Sie, ob sich der Benutzer in der Datenbank befindet.
Ich versuche, Google Anmeldung in meine Flutter-Android-App mit der Firebase-Authentifizierung zu integrieren, aber jeder Versuch endet mit (dies geschah nur bei der Veröffentlichung):...