小编pil*_*noy的帖子

服务器端 Blazor 中的 Google 身份验证不起作用

我正在尝试在 Blazor 服务器应用程序上添加 Google 身份验证,但无法在我的本地主机上运行。当我单击“登录”按钮时,它会将我带到 Google 帐户选择器,在那里我选择一个用于登录的帐户。选择一个帐户后,它返回到我的 localhost 登录页面,其中 OnGetCallbackAsync 显示 GoogleUser.IsAuthenticated 是错误的。

下面是 Startup.cs

namespace RecruitmentApp
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<ApplicationDbContext>(options =>
            options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
                //options.UseSqlite("DataSource=app.db"));
            services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = false)
                .AddEntityFrameworkStores<ApplicationDbContext>(); …
Run Code Online (Sandbox Code Playgroud)

c# google-authentication asp.net-core blazor

7
推荐指数
0
解决办法
815
查看次数

标签 统计

asp.net-core ×1

blazor ×1

c# ×1

google-authentication ×1