Asp.NetReact项目模板Google身份验证无法工作。
创始人
2024-11-12 06:30:24
0
  1. 确认Google API密钥是否正确设置。在Google API控制台中,检查是否已启用了Google认证。确保在项目中正确设置了clientId和clientSecret。具体可以参考以下代码示例:
services.AddAuthentication()
    .AddGoogle(options =>
    {
        IConfigurationSection googleAuthNSection =
            Configuration.GetSection("Authentication:Google");

        options.ClientId = googleAuthNSection["ClientId"];
        options.ClientSecret = googleAuthNSection["ClientSecret"];
    });
  1. 检查前端URL是否正确设置。在Google API控制台中,确保已正确设置了授权JavaScript来源和重定向URI。具体代码示例如下:
const response = await fetch("/authentication/login/google?returnUrl=" + encodeURIComponent("/"), { method: "POST" });
const result = await response.json();
window.location.href = result.redirectUrl;
  1. 确认后端URL是否正确设置。在Asp.Net项目中,检查是否已正确设置Google身份验证的回调URL。具体代码示例如下:
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
    ClientId = "xxxxxxxxxx",
    ClientSecret = "xxxxxxxxxx",
    CallbackPath = new PathString("/signin-google"),
});

进行以上步骤后,Google身份验证应该可以正常工作。

相关内容

热门资讯

透视曝光"wepok... 透视曝光"wepoker私人局规律"都是有辅助软件(哔哩哔哩)1、wepoker私人局规律透视辅助软...
透视分享"werpl... 透视分享"werplan有挂吗"原来有辅助神器(哔哩哔哩)该软件可以轻松地帮助玩家将werplan有...
透视推荐"hhpok... 透视推荐"hhpoker是真的吗"原来真的有辅助app(哔哩哔哩)1、下载好hhpoker是真的吗脚...
透视总结"约局吧德州... 透视总结"约局吧德州透视"好像真的是有辅助器(哔哩哔哩)1、下载好约局吧德州透视透视辅助下载之后点击...
透视分享"wepok... 透视分享"wepoker透视最简单三个步骤"一贯存在有辅助技巧(哔哩哔哩)一、wepoker透视最简...
透视揭幕"拱趴大菠萝... 透视揭幕"拱趴大菠萝机器人"一贯是有辅助攻略(哔哩哔哩)该软件可以轻松地帮助玩家将拱趴大菠萝机器人外...
透视科普"wepok... 您好,wepokerh5破解这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】...
透视详情"德普之星透... 透视详情"德普之星透视辅助软件是真的吗"一直有辅助器(哔哩哔哩)1)德普之星透视辅助软件是真的吗辅助...
透视必备"hhpok... 透视必备"hhpoker可以开挂吗"一贯真的有辅助神器(哔哩哔哩)1、起透看视 hhpoker可以开...
透视开挂"wepok... 透视开挂"wepoker有人用过吗"本来真的有辅助插件(哔哩哔哩)1、下载好wepoker有人用过吗...