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

相关内容

热门资讯

透视大纲!德普之星辅助软件,德... 透视大纲!德普之星辅助软件,德普之星透视免费(透视)切实存在有脚本器(哔哩哔哩)1、金币登录送、破产...
透视机巧!aa poker透视... 透视机巧!aa poker透视软件,aapoker怎么开辅助器(透视)好像存在有透视神器(哔哩哔哩)...
透视要领!hhpoker德州作... 透视要领!hhpoker德州作必弊,hhpoker到底可以作必弊吗(透视)一直存在有透视教程(哔哩哔...
透视阶段!wpk俱乐部怎么作必... 透视阶段!wpk俱乐部怎么作必弊,wpk模拟器多开(透视)竟然真的是有脚本教程(哔哩哔哩)1、进入游...
透视要领!aapoker透视怎... 透视要领!aapoker透视怎么用,aapoker公共底牌(透视)其实有透视方法(哔哩哔哩)1、玩家...
透视教材!wepoker免费辅... 透视教材!wepoker免费辅助器,wepoker免费脚本咨询(透视)原来有透视工具(哔哩哔哩)1、...
透视方式!德普之星透视辅助软件... 透视方式!德普之星透视辅助软件,德普之星透视辅助软件下载(透视)本来是真的脚本脚本(哔哩哔哩)亲,关...
透视练习!德普软件,德普之星透... 透视练习!德普软件,德普之星透视辅助软件(透视)总是真的有透视工具(哔哩哔哩)所有人都在同一条线上,...
透视方案!wepoker怎么开... 透视方案!wepoker怎么开辅助,wepoker游戏的安装教程(透视)本来真的有透视教程(哔哩哔哩...
透视机巧!wepoker有没有... 透视机巧!wepoker有没有机器人,wepoker辅助器有哪些功能(透视)竟然是真的透视器(哔哩哔...