c# - 如何设置redirect_uri登录google .Net Core 2,Docker
问题描述
我正在尝试在 .net core 2 docker 中使用 google 进行身份验证
services
.AddAuthentication(options =>
{
options.DefaultSignOutScheme = IdentityConstants.ApplicationScheme;
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddGoogle("Google", options =>
{
options.CallbackPath = "/api/i/v1/identity/handle-external-login/Google/callback";
options.ClaimActions.MapJsonKey("urn:google:picture", "picture", "url");
options.ClaimActions.MapJsonKey("urn:google:locale", "locale", "string");
options.SaveTokens = true;
options.ClientId = Configuration["Authentication:Google:ClientId"];
options.ClientSecret = Configuration["Authentication:Google:ClientSecret"];
options.Events = new OAuthEvents
{
OnRemoteFailure = (RemoteFailureContext context) =>
{
context.Response.Redirect("/home/denied");
context.HandleResponse();
return Task.CompletedTask;
}
};
})
[HttpGet("signin-{provider}")]
[AllowAnonymous]
public IActionResult SignInWithGoogle(string provider)
{
var redirectUrl = Url.Action(nameof(HandleExternalLogin), "Identity", new { provider });
var authenticationProperties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
return Challenge(authenticationProperties, provider);
}
当重定向到谷歌登录页面时:
400. That’s an error.
Error: invalid_request
Invalid parameter value for redirect_uri: Non-public domains not allowed: http://identity.service/api/i/v1/identity/handle-external-login/Google/callback
如何将 identity.service 更改为 localhost 或其他内容?对不起,我的英语不好,
解决方案
推荐阅读
- svelte - Svelte 中的单身人士
- firebase - 使用 Firebase 托管时,视频 (.mp4) 无法在 Safari 中加载
- postgresql - 对 postgreSQL v12 触发器的 COPY 支持
- swift - Swift Inject Javascript 将 HTML 元素删除到 WebView
- javascript - ondrag 事件在 Chromium 上不起作用
- javascript - 如何使用其名称返回对象数组的键
- android - 2021 年 3 月 31 日之后可以使用旧版 Firebase Push 吗?
- r - 使用数据框列更改因子级别
- javascript - 除了使用Javascript的单个特定div之外,如何刷新一个whoke oage?
- python - 如何使用 Python 提取特定行?