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...
解迷透视!sohoopoker... 解迷透视!sohoopoker辅助!一直一直都是有辅助教程(有挂方针)-哔哩哔哩1、sohoopok...
必备透视!wpk是真的还是假的... 必备透视!wpk是真的还是假的,wepoker手机版辅助,法门教程(确实有挂)-哔哩哔哩1、任何wp...
解密透视!pokerworld... 解密透视!pokerworld修改器!一贯一直总是有辅助方法(有挂教程)-哔哩哔哩pokerworl...
必备透视!wepokerplu... 必备透视!wepokerplus外开挂,wepoker透视功能下载,模块教程(有挂教程)-哔哩哔哩1...
教你透视!pokermaste... 教你透视!pokermaster修改器!真是有辅助插件(有人有挂)-哔哩哔哩1、进入游戏-大厅左侧-...
有挂透视!wepoker有透视... 有挂透视!wepoker有透视吗,wepoker俱乐部辅助,大纲教程(今日头条)-哔哩哔哩1、起透看...
总结透视!wepoker透视脚... 总结透视!wepoker透视脚本免费下载pc,epoker透视底牌,机巧教程(真是有挂)-哔哩哔哩1...
揭露透视!werplan免费挂... 揭露透视!werplan免费挂下载!一直真的有辅助技巧(有挂详细)-哔哩哔哩1、玩家可以在werpl...
教你透视!werplan怎么透... 教你透视!werplan怎么透视,wepoker免费脚本咨询,手册教程(真实有挂)-哔哩哔哩1、让任...