您好,我正在学习如何连接到Microsoft Graphs,我按照教程进行操作,但是对我来说它不起作用,它显示了此错误
Message: An error occurred sending the request.
)
---> Status Code: 0
Microsoft.Graph.ServiceException: Code: generalException
Message: An error occurred sending the request.
---> MSAL.NetCore.4.14.0.0.MsalServiceException:
ErrorCode: accessing_ws_metadata_exchange_failed
Microsoft.Identity.Client.MsalServiceException: Response status code does not indicate success: 406 (NotAcceptable).
at Microsoft.Identity.Client.WsTrust.WsTrustWebRequestManager.GetMexDocumentAsync(String federationMetadataUrl, RequestContext requestContext)
at Microsoft.Identity.Client.WsTrust.CommonNonInteractiveHandler.PerformWsTrustMexExchangeAsync(String federationMetadataUrl, String cloudAudienceUrn, UserAuthType userAuthType, String username, SecureString password)
at Microsoft.Identity.Client.Internal.Requests.UsernamePasswordRequest.FetchAssertionFromWsTrustAsync()
at Microsoft.Identity.Client.Internal.Requests.UsernamePasswordRequest.ExecuteAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenByUsernamePasswordParameters usernamePasswordParameters, CancellationToken cancellationToken)
at Helpers.MsalAuthenticationProvider.GetTokenAsync() in C:\Users\Will\Downloads\Teste\graphconsoleapp\Helpers\MsalAuthenticationProvider.cs:line 62
at Helpers.MsalAuthenticationProvider.AuthenticateRequestAsync(HttpRequestMessage request) in C:\Users\Will\Downloads\Teste\graphconsoleapp\Helpers\MsalAuthenticationProvider.cs:line 40
at Microsoft.Graph.AuthenticationHandler.SendAsync(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Microsoft.Graph.HttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
StatusCode: 406
ResponseBody:
Headers: Server: Microsoft-IIS/10.0
PPServer: PPV: 30 H: BL02PFE54DD391D V: 0
Access-Control-Allow-Origin: *
Date: Thu, 18 Jun 2020 15:18:29 GMT
Connection: close
--- End of inner exception stack trace ---
at Microsoft.Graph.HttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at Microsoft.Graph.BaseRequest.SendAsync[T](Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at Microsoft.Graph.DriveItemChildrenCollectionRequest.GetAsync(CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at graphconsoleapp.Program.Main(String[] args) in C:\Users\Will\Downloads\Teste\graphconsoleapp\Program.cs:line 32
我知道此电话涉及
var results = request.GetAsync().Result;
我正在使用注册为microsoft acc的google acc,我不知道这是否是一个问题,但是我按照了教程中的每个步骤操作,对我来说不起作用。
感谢您的时间。