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

相关内容

热门资讯

透视线上!拱趴大菠萝十三水辅助... 透视线上!拱趴大菠萝十三水辅助,aapoker透视方法,攻略教程(总是是有挂)-哔哩哔哩1)拱趴大菠...
透视靠谱!购买的wpk辅助在哪... 透视靠谱!购买的wpk辅助在哪里下载(透视)开挂辅助脚本(一直存在有挂)-哔哩哔哩1、全新机制【购买...
透视脚本!fishpoker透... 透视脚本!fishpoker透视底牌,aapoker脚本怎么用,模板教程(真是有挂)-哔哩哔哩1、透...
透视ios!约局吧开挂神器是真... 您好,约局吧开挂神器是真的吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】...
透视总结!wepoker有透视... 透视总结!wepoker有透视吗,wepoker轻量版透视,练习教程(果然真的有挂)-哔哩哔哩1、实...
透视插件!红龙poker辅助工... 透视插件!红龙poker辅助工具(透视)开挂辅助挂(总是真的有挂)-哔哩哔哩1)红龙poker辅助工...
透视教学!hhpoker怎么开... 透视教学!hhpoker怎么开透视,wepoker买钻石有用吗,策略教程(竟然有挂)-哔哩哔哩1、w...
透视数据!pokemmo手机版... 透视数据!pokemmo手机版脚本(透视)开挂辅助软件(一贯是真的挂)-哔哩哔哩1、全新机制【pok...
透视代打!wpk模拟器是什么,... 透视代打!wpk模拟器是什么,uupoker透视,窍门教程(其实是有挂)-哔哩哔哩1、不需要AI权限...
透视德州版!HH平台挂(透视)... 透视德州版!HH平台挂(透视)开挂辅助方法(其实真的有挂)-哔哩哔哩1、下载好HH平台挂辅助软件之后...