使用本地客户端凭据连接到 Azure Blob 存储

Connecting to Azure Blob Storage using Client Credential from on-premises

我正在尝试使用 ClientID 和 ClientSecret 与受 Azure AD 保护的 Azure Blob 存储进行交互。当我在 Visual Studio 上从我的机器 运行 运行应用程序时,它工作正常,但是当我从本地 VM 运行 运行应用程序时,我收到此错误:

An error response was returned by the OAuth2 server, but it could not be parsed. Please inspect the exception properties for details. 
 ---> MSAL.NetCore.4.30.1.0.MsalServiceException: 
ErrorCode: non_parsable_oauth_error
Microsoft.Identity.Client.MsalServiceException: An error response was returned by the OAuth2 server, but it could not be parsed. Please inspect the exception properties for details. 
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.HandleTokenRefreshError(MsalServiceException e, MsalAccessTokenCacheItem cachedAccessTokenItem)
   at Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.ExecuteAsync(CancellationToken cancellationToken)
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)
   at Microsoft.Identity.Client.ApiConfig.Executors.ConfidentialClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenForClientParameters clientParameters, CancellationToken cancellationToken)
   at Azure.Identity.AbstractAcquireTokenParameterBuilderExtensions.ExecuteAsync[T](AbstractAcquireTokenParameterBuilder`1 builder, Boolean async, CancellationToken cancellationToken)
   at Azure.Identity.MsalConfidentialClient.AcquireTokenForClientAsync(String[] scopes, Boolean async, CancellationToken cancellationToken)
   at Azure.Identity.ClientSecretCredential.GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
StatusCode: 407 

看起来您正在通过代理访问 Oauth 端点

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407

The HTTP 407 Proxy Authentication Required client error status response code indicates that the request has not been applied because it lacks valid authentication credentials for a proxy server that is between the browser and the server that can access the requested resource.

您需要检查 VM 和 OAuth 服务器之间的连接属性