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身份验证应该可以正常工作。

相关内容

热门资讯

透视详情"aapok... 透视详情"aapoker辅助工具安全吗"真是真的有辅助技巧(哔哩哔哩)1、aapoker辅助工具安全...
透视曝光"wepok... 透视曝光"wepoker透视底牌脚本"原来真的是有辅助app(哔哩哔哩)1、下载好wepoker透视...
透视解谜"wepok... 透视解谜"wepoker透视脚本免费下载"其实是有辅助技巧(哔哩哔哩)1、起透看视 wepoker透...
透视教你"hhpok... 您好,hhpoker视频巡查真的假的这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704...
透视专业"拱趴大菠萝... 透视专业"拱趴大菠萝作必弊方法"其实是有辅助脚本(哔哩哔哩)1、拱趴大菠萝作必弊方法脚本辅助下载、拱...
透视有挂"拱趴大菠萝... 透视有挂"拱趴大菠萝自动计算机器人"确实真的有辅助器(哔哩哔哩)1、拱趴大菠萝自动计算机器人破解器简...
透视必备"约局吧怎么... 透视必备"约局吧怎么看有没有挂"真是存在有辅助攻略(哔哩哔哩)1、约局吧怎么看有没有挂免费脚本咨询教...
透视透视"xpoke... 透视透视"xpoker辅助"果然真的有辅助脚本(哔哩哔哩)进入游戏-大厅左侧-新手福利-激活码辅助透...
透视了解"wepok... 透视了解"wepoker可以免费玩吗"原来有辅助技巧(哔哩哔哩)1、玩家可以在wepoker可以免费...
透视透视"wepok... 透视透视"wepoker辅助透视软件"一直是有辅助器(哔哩哔哩)1、完成wepoker辅助透视软件辅...