c# - Microsoft ADD - 应用程序注册 - 请求中指定的回复网址与配置的回复网址不匹配

标签 c# oauth azure-active-directory

我创建了一个使用 Azure Active Directory 身份验证的 Web 应用程序。

在本地主机上一切正常,但是当我将应用程序发布到 Azure 时出现以下错误:

AADSTS50011: The reply url specified in the request does not match the reply urls configured for the application: '656cc46c-f858-4a45-bf83-698791e052f1'.

我尝试过的:

在 Azure 中,我将相关应用程序的回复 URL 配置为:

http://gp-rh.azurewebsites.net/signin-oidc

这是我的 appsetting.json:

{
  "AzureAd": {
    "Instance": "https://login.microsoftonline.com/",
    "Domain": "legroupeti.com",
    "TenantId": "7c6ff5e2-0660-4b65-9b64-7a78df412819",
    "ClientId": "656cc46c-f858-4a45-bf83-698791e052f1",
    "CallbackPath": "/signin-oidc"
  },
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  }
}

在我的应用程序中,执行登录的 Controller 设置如下:

[HttpGet]
public IActionResult SignIn() {
    var redirectUrl = Url.Action("Index", "Dashboard",
        new { date = DateTime.Now, anchor = "period" });
    return Challenge(
        new AuthenticationProperties { RedirectUri = redirectUrl },
        OpenIdConnectDefaults.AuthenticationScheme);
}

我的应用程序的默认页面是 /,它重定向到 /Dashboard

不知道哪里出错了,还是不行。

最佳答案

redirect_uri 必须完全匹配您注册的 URI 之一,包括方案(http://https://)。

一般来说,您应该将不安全的方案 (http) 用于开发目的。对于测试/阶段/生产,您应该始终使用安全连接 (https)。在这种情况下,绝对没有理由不使用 https://gp-rh.azurewebsites.net/signin-oidc,因为 azurewebsites.net 默认支持 HTTPS。

关于c# - Microsoft ADD - 应用程序注册 - 请求中指定的回复网址与配置的回复网址不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50957573/

相关文章:

java - 在 Java Web App 中集成 Google 的 OAuth/OpenID 混合库?

c# - Azure AD : AcquireTokenAsync for a native app fails when appRoleAssignmentRequired = true

c# - Dapper 强类型查询返回默认对象值

c# - 计算平均值时是否可以使用 Skip and Take?

oauth - 有什么方法可以结合客户端和服务器端 Google API 身份验证?

php - Pinterest 身份验证 url 返回 404 错误?

Azure B2C 租户和图形 API、用户管理

c# - 使用 Microsoft 图形 API 工作帐户发送电子邮件

c# - 将日期时间转换为没有默认时间值的字符串

c# - nuget : .net core中的打包项目引用