例外:尝试使用 Microsoft 登录时关联失败

灰熊

遵循有关如何从此处添加 Microsoft 帐户登录的文档后,我收到以下异常。关于这个问题还有很多其他问题,但没有一个解决方案对我有用。

我正在使用默认的 Identity 实现(项目创建时的个人用户帐户)。

异常图像

启动.cs:

public void ConfigureServices(IServiceCollection services)
    {
        services.AddBlazorise(options =>
        {
            options.ChangeTextOnKeyPress = true; // optional
        })
        .AddBootstrapProviders()
        .AddFontAwesomeIcons();

        services.AddDbContext<UserDbContext>(options =>
            options.UseSqlServer(
                Configuration.GetConnectionString("ASPIdentityDB")));

        services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
            .AddEntityFrameworkStores<UserDbContext>();

        services.AddAuthentication().AddMicrosoftAccount(options =>
        {
            options.ClientId = Configuration["Authentication:Microsoft:ClientId"];
            options.ClientSecret = Configuration["Authentication:Microsoft:ClientSecret"];
        });

        services.AddRazorPages();
        services.AddServerSideBlazor();
        services.AddScoped<AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider<ApplicationUser>>();
        services.AddDatabaseDeveloperPageExceptionFilter();

        services.AddSingleton<WeatherForecastService>();

        services.AddResponseCompression(opts =>
        {
            opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
                new[] { "application/octet-stream" });
        });

        services.AddSingleton<IUserIdProvider, NameUserIdProvider>();
        services.AddSignalR();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseResponseCompression();

        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseMigrationsEndPoint();
        }
        else
        {
            app.UseExceptionHandler("/Error");
            // 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.UseStaticFiles();

        app.UseRouting();

        app.UseAuthentication();
        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
            endpoints.MapBlazorHub();
            endpoints.MapFallbackToPage("/_Host");
        });
    }

蔚蓝配置: Azure 配置

灰熊

我的解决方案是添加这个简单的 cookie 策略:

app.UseCookiePolicy(new CookiePolicyOptions()
            {
                HttpOnly = HttpOnlyPolicy.Always,
                Secure = CookieSecurePolicy.Always,
                MinimumSameSitePolicy = SameSiteMode.None
            });

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Microsoft身份验证自动登录帐户。用户手动选择帐户时,导致“关联失败”错误

Azure EasyAuth:尝试使用Microsoft帐户登录时出现未授权错误

使用Python请求模块时尝试/例外

当Microsoft帐户与Windows登录相关联时,如何登录到网络共享?

尝试登录时,Firefox的Selenium测试失败

无法使用Microsoft帐户登录

使用JWT和Spring时登录失败

使用Microsoft身份提供程序登录失败,可用于其他提供程序

使用个人Microsoft帐户登录失败到Oauth2 v2

尝试使用$ expand(microsoft.graph.itemattachment / item)读取ItemAttachment属性时,Microsoft Graph API“拒绝访问”

Microsoft SQL Server:“登录失败。登录来自不受信任的域,不能与Windows身份验证一起使用。”

在尝试关联条目时将多对多序列化失败并显示“未关联到”吗?

登录尝试失败时AWS IAM帐户锁定

3次登录尝试失败时禁用文本框

Terraform UnsupportedOperation:尝试启动Amazon-Linux实例时使用Microsoft SQL

Firebase Auth REST - 使用 Microsoft Provider 登录

尝试使用Spring Security定制失败的登录

使用Laravel 5.2记录失败的登录尝试

尝试使用LibGDX登录GooglePlay游戏服务时出现“ signInSilently():失败”

安装Microsoft Online Services登录助手时,Oracle IAM / WNA协议回退到基于表单的登录页面失败

尝试登录失败

如何解决使用Microsoft帐户登录时AADSTS700016错误?

MSAL - 尝试对 Microsoft Graph 登录进行身份验证时无法将项目设置到钥匙串中

例外:关联失败。位置不明

Laravel 5.6登录尝试失败-登录提交时返回方法RequestGuard :: attempt不存在

如果无法识别引用,但使用Microsoft.NET.Sdk.Razor时发布失败

页面:使用 OneNote 和 Microsoft 图形 API 时,copyToSection 失败,错误代码为 19999

无法使用 Azure 登录的 Microsoft Exchange 帐户登录

尝试下载用户图像时出现Microsoft.Graph.ServiceException