【问题标题】:Query Identities with VSTS client libraries使用 VSTS 客户端库查询身份
【发布时间】:2016-06-30 19:54:32
【问题描述】:

当我从 Microsoft.VisualStudio.Services.Client nuget 包对 IdentityHttpClient 调用 ReadIdentitiesAsync 时:

using (var client = new IdentityHttpClient(baseUrl, credentials))
{
    identities = await client.ReadIdentitiesAsync(IdentitySearchFilter.General, "user@company.com");
}

抛出此异常:

API 资源位置 28010c54-d0c0-4c89-a5b0-1c9e188b9fb7 未在 https://myaccount.visualstudio.com/ 上注册

我应该使用另一个 uri 吗?

【问题讨论】:

    标签: .net azure-devops


    【解决方案1】:

    用于身份 api 的基本 url 与其他 api 不同。

    对于客户端库中的大多数客户端,使用https://myaccount.visualstudio.com

    对于身份客户端,使用https://myaccount.vssps.visualstudio.com

    【讨论】:

      【解决方案2】:

      将它与 VSTS 一起使用时,我遇到了同样的异常,但代码可以在本地 TFS 服务器上正常工作。

      作为替代方式,您可以使用.NET client libraries API 获取身份信息。

      using System;
      using Microsoft.TeamFoundation.Client;
      using Microsoft.TeamFoundation.Server;
      
      namespace NetAPIID
      {
          class Program
          {
              static void Main(string[] args)
              {
                  string url = "https://xxx.visualstudio.com";
      
                  TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(url));
                  ttpc.EnsureAuthenticated();
      
                  IGroupSecurityService igss = ttpc.GetService<IGroupSecurityService>();
      
                  Identity id = igss.ReadIdentity(SearchFactor.AccountName, "user@company.com", QueryMembership.None);
              }
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-08-29
        • 1970-01-01
        • 2023-02-06
        • 2011-11-30
        • 2015-09-24
        • 2016-07-09
        • 1970-01-01
        相关资源
        最近更新 更多