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

相关内容

热门资讯

分享认知!hhpoker有辅助... 分享认知!hhpoker有辅助吗(辅助挂)真是是有挂(存在有挂)1、超多福利:超高返利,海量正版游戏...
科普分享!pokemmo脚本(... 科普分享!pokemmo脚本(辅助挂)一贯是真的有挂(发现有挂)1、pokemmo脚本公共底牌简单,...
一分钟带你了解!WePoKer... 一分钟带你了解!WePoKer辅助器(辅助挂)切实存在有挂(有挂方法)1、WePoKer辅助器脚本辅...
揭秘关于!黑侠破解wepoke... 揭秘关于!黑侠破解wepoker(辅助挂)原来是真的有挂(了解有挂)1、揭秘关于!黑侠破解wepok...
避坑细节!hh poker辅助... 避坑细节!hh poker辅助器先试用(辅助挂)果然是真的有挂(有挂秘笈)1、hh poker辅助器...
发现一款!佛手在线有挂吗(辅助... 您好,佛手在线有挂吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家...
来一盘!wepoker怎么提高... 来一盘!wepoker怎么提高运气(辅助挂)本来是真的有挂(有人有挂)1、wepoker怎么提高运气...
揭秘一下!悟空黑桃a有挂嘛(辅... 揭秘一下!悟空黑桃a有挂嘛(辅助挂)本来是真的有挂(有挂方略)悟空黑桃a有挂嘛能透视中分为三种模型:...
玩家必看教程!wepoker可... 玩家必看教程!wepoker可以免费玩吗(辅助挂)一贯有挂(确实有挂)1、首先打开wepoker可以...
玩家爆料!wejoker辅助器... 玩家爆料!wejoker辅助器怎么卖(辅助挂)好像是真的有挂(有挂教程)玩家爆料!wejoker辅助...