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

相关内容

热门资讯

现场直击!wepoker私人局... 现场直击!wepoker私人局外卦(透视)总是是真的辅助工具(真是有挂)-哔哩哔哩小薇(辅助器软件下...
透视存在!德普之星辅助工具如何... 透视存在!德普之星辅助工具如何打开(透视)果然存在有辅助修改器(存在有挂)-哔哩哔哩1)德普之星辅助...
透视好牌!hhpoker德州机... 透视好牌!hhpoker德州机器人(透视)切实存在有辅助辅助器(有挂秘诀)-哔哩哔哩1、hhpoke...
透视计算!德州局怎么透视(透视... 透视计算!德州局怎么透视(透视)好像真的有辅助安装(新版有挂)-哔哩哔哩1、操作简单,无需德州局怎么...
突发!epoker透视(透视)... 突发!epoker透视(透视)竟然真的是有辅助app(有挂实锤)-哔哩哔哩1、许多玩家不知道epok...
日前!pokemmo辅助器手机... 日前!pokemmo辅助器手机版下载(透视)一直有辅助辅助器(竟然有挂)-哔哩哔哩1、进入到poke...
据玩家消息!wepoker轻量... 据玩家消息!wepoker轻量版有透视吗(透视)总是有辅助平台(有挂详情)-哔哩哔哩1、wepoke...
更值得关注的是!wepoker... 更值得关注的是!wepoker怎么看牌型(透视)好像真的是有辅助软件(有挂秘诀)-哔哩哔哩1、实时w...
透视黑科技!hhpoker怎么... 透视黑科技!hhpoker怎么破解(透视)总是真的是有辅助安装(真的有挂)-哔哩哔哩1、首先打开hh...
透视私人局!hhpoker是正... 透视私人局!hhpoker是正规的吗(透视)确实存在有辅助下载(有挂功能)-哔哩哔哩1)hhpoke...