使用Microsoft.SDK.Graph中的GraphClient,我可以看到查询在fiddler中发出,它们都没有使用HTTP/2.0,但我得到以下错误:
参数异常:当前仅支持HTTP/1.0和HTTP/1.1版本请求。参数名:价值
private async Task<UserAccount> FetchAzurePropsFromGraph()
{
var scopes = new[] { "User.Read" };
var clientId = EWSMailboxSyncProvider.CLIENT_ID;
var tenantId = ServicesConfiguration.GetStoredTenantID();
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
var transport = new Azure.Core.Pipeline.HttpClientTransport(client);
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
Transport = transport
};
var userNamePasswordCredential = new UsernamePasswordCredential(
_o365UserName, _o365Password, tenantId, clientId, options);
var graphClient = new Microsoft.Graph.GraphServiceClient(userNamePasswordCredential, scopes);
var user = await graphClient.Users[_emailAddress].Request().GetAsync();
var result = new UserAccount();
if (user != null)
{
result.DisplayName = user.DisplayName;
result.City = user.City;
result.Company = user.CompanyName;
result.DisabledAccount = !(user.AccountEnabled ?? true);
result.DistinguishedName = user.OnPremisesDistinguishedName;
result.DomainName = user.OnPremisesDomainName;
result.EmailAddresses.Add(user.Mail);
foreach (var mail in user.OtherMails)
{
result.EmailAddresses.Add(mail);
}
}
return result;
}
1条答案
按热度按时间gudnpqoy1#
我和你有同样的问题,我通过创建自定义请求到微软服务器解决了它
在获得访问令牌后,我创建了一个请求,并使用以下访问令牌向服务器发送请求:
您可以阅读此文档,创建更多的请求,如示例GetMailBox i放在上面Microsoft Graph API document