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、佛手大菠萝辅助...
普及透视!wepoker有辅助... 普及透视!wepoker有辅助工具吗,微信微乐小程序辅助软件,手筋教程(有挂讲解)-哔哩哔哩1、任何...
教你透视!拱趴大菠萝挂,微乐陕... 教你透视!拱趴大菠萝挂,微乐陕西小程序辅助,操作教程(有挂方法)-哔哩哔哩1、完成拱趴大菠萝挂有辅助...
普及透视!fishpoker透... 普及透视!fishpoker透视底牌,微乐河南麻将辅助ios,学习教程(有挂方针)-哔哩哔哩1、这是...
解密透视!poker红龙辅助,... 解密透视!poker红龙辅助,微乐自建房辅助多少钱一个月,指南教程(有挂总结)-哔哩哔哩1、完成po...
开挂透视!hhpoker透视脚... 开挂透视!hhpoker透视脚本,微乐小程序多乐辅助器,方针教程(有挂秘籍)-哔哩哔哩1、不需要AI...
开挂透视!we poker辅助... 开挂透视!we poker辅助器v3.3,微乐贵阳捉鸡麻将挂软件,手筋教程(有挂透明挂)-哔哩哔哩1...
开挂透视!pokemmo免费脚... 开挂透视!pokemmo免费脚本,微乐小程序透视工具,手段教程(证实有挂)-哔哩哔哩1、操作简单,无...
详情透视!wepoker免费透... 详情透视!wepoker免费透视脚本,微乐自建房脚本免费下载,妙招教程(竟然有挂)-哔哩哔哩详情透视...
开挂透视!wepoker私人辅... 开挂透视!wepoker私人辅助器,微乐小程序修复系统有用吗,模板教程(有挂神器)-哔哩哔哩所有人都...