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辅助软... 透视专业!aapoker辅助软件合法吗(透视)佛手大菠萝有挂吗,教程法子(有挂秘笈)-哔哩哔哩一、a...
透视必备!pokemmo脚本辅... 透视必备!pokemmo脚本辅助器下载(透视)聚星ai辅助工具收费多少,教程演示(有挂方法)-哔哩哔...
透视揭露!aapoker插件(... 透视揭露!aapoker插件(透视)wepoker透视苹果系统,教程绝活(有挂教程)-哔哩哔哩1、在...
透视必备!德普之星私人局透视(... 透视必备!德普之星私人局透视(透视)wepoker开辅助能查到吗,教程操作(有人有挂)-哔哩哔哩1、...
透视有挂!wepoker私人局... 透视有挂!wepoker私人局透视插件(透视)佛手在线大菠萝为什么都输,教程大纲(有挂功能)-哔哩哔...
透视普及!hhpoker智能辅... 透视普及!hhpoker智能辅助插件(透视)hhpoker辅助器,教程经验(确实有挂)-哔哩哔哩1、...
透视解密!wejoker辅助器... 透视解密!wejoker辅助器怎么卖(透视)德州来玩辅助器,教程烘培(有挂存在)-哔哩哔哩1、进入游...
透视透视!wepoker辅助器... 透视透视!wepoker辅助器免费(透视)红龙poker辅助,教程妙计(果真有挂)-哔哩哔哩1.we...
透视解迷!hhpoker辅助器... 透视解迷!hhpoker辅助器视频(透视)wepoker买脚本靠谱吗,教程步骤(有挂详情)-哔哩哔哩...
透视了解!pokemmo辅助官... 透视了解!pokemmo辅助官网(透视)wepoker私人局外卦,教程讲义(真是有挂)-哔哩哔哩运w...