在名为test113.onmicrosoft.com的租户中找不到名为HTTPS://test113.onmicrosoft.com/FTP的应用程序 [英] The application named HTTPS://test113.onmicrosoft.com/FTP was not found in the tenant named test113.onmicrosoft.com

查看:64
本文介绍了在名为test113.onmicrosoft.com的租户中找不到名为HTTPS://test113.onmicrosoft.com/FTP的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须根据Azure AD对应用程序进行身份验证.我已经创建了Web API,并将其添加到Azure AD应用程序部分.更改清单文件,创建Web API并通过Azure AD进行身份验证,并创建Windows表单,其中包含以下代码:

I have to authenticate an application against Azure AD. I have created the web API and added it to the Azure AD application section. Changed the manifest file, created a web API and authenticated with the Azure AD and created a Windows form, containing the following code:

 private async void button1_Click(object sender, EventArgs e)
 {
    string authority = "https://login.windows.net/test113.onmicrosoft.com";
    string resourceURI = "https://test113.onmicrosoft.com/ftp";
    string clientID = "5177ef76-cbb4-43a8-a7d0-899d3e886b34";
    Uri returnURI = new Uri("http://keoftp");

    AuthenticationContext authContext =
        new AuthenticationContext(authority);
    AuthenticationResult authResult =
        authContext.AcquireToken(resourceURI, clientID, returnURI);

    string authHeader = authResult.CreateAuthorizationHeader();

    // don't do this in prod
    System.Net.ServicePointManager.ServerCertificateValidationCallback =
            ((s, c, c2, se) => true);

    HttpClient client = new HttpClient();
    HttpRequestMessage request =
        new HttpRequestMessage(HttpMethod.Get, "https://localhost:44300/api/tasks");
    request.Headers.TryAddWithoutValidation("Authorization", authHeader);
    var response = await client.SendAsync(request);
    string responseString = await response.Content.ReadAsStringAsync();
    MessageBox.Show(responseString);
}

我有一个例外:

类型的异常 'Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException' 发生在Microsoft.IdentityModel.Clients.ActiveDirectory.dll中,但 没有用用户代码处理

An exception of type 'Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException' occurred in Microsoft.IdentityModel.Clients.ActiveDirectory.dll but was not handled in user code

其他信息:AADSTS50001:该应用程序名为 在名为租户"的租户中找不到 https://test113.onmicrosoft.com/ftp test113.onmicrosoft.com.如果应用程序没有,则会发生这种情况 由租户的管理员安装或得到租户的同意 租户中的任何用户.您可能已经发送了身份验证 请求给错误的租户.

Additional information: AADSTS50001: The application named https://test113.onmicrosoft.com/ftp was not found in the tenant named test113.onmicrosoft.com. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant.

跟踪ID:e782d60e-b861-46a3-b32b-f3df78396bd0 相关ID: b4809815-2755-4de1-bd1b-0221d74fd0f0时间戳记:2016-03-17 11:20:08Z

Trace ID: e782d60e-b861-46a3-b32b-f3df78396bd0 Correlation ID: b4809815-2755-4de1-bd1b-0221d74fd0f0 Timestamp: 2016-03-17 11:20:08Z

推荐答案

请求中的资源是指您要在特定租户中访问的资源.当本机客户端需要从Azure Active Directory获取令牌时,它需要指定想要令牌的资源.在这种情况下,客户端应用程序希望访问Web API,因此该Web API的 APP ID URI被用作资源名称.拥有令牌后,它还需要知道可以访问资源的URL,在这种情况下,就是Web API的地址.例如:

Resource in the request means the resource which you want to access in the particular tenant. When a native client needs to get a token from Azure Active Directory, it needs to specify the resource it wants a token for. In this scenario the client application wants access to the Web API so the APP ID URI for the Web API is used as the resource name. After it has the token it also needs to know the URL where the resource can be accessed, in this case the address of the Web API.For example:

// Resource settings this application wants to access
private string resource = "https://cloudalloc.com/CloudAlloc.WebAPI";
private Uri WebAPIUri = new Uri("https://localhost:44313");

这两项设置都可以在Azure管理门户中Web API应用程序的CONFIGURE页的单点登录"部分中找到.

Both of these settings can be found in the single sign-on section of the CONFIGURE page for the Web API application in the Azure Management portal.

点击此处了解更多详细信息.

Click here for more details .

这篇关于在名为test113.onmicrosoft.com的租户中找不到名为HTTPS://test113.onmicrosoft.com/FTP的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆