I found this solution and for me it works.
https://blog.jongallant.com/2021/08/visual-studio-re-enter-credentials/
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am unable to create new connections to my Azure account from Visual Studio. For example, I can no longer create new connections to application insights or create a new publish profile when publishing to an Azure App Service from Visual Studio.
When clicking "Sign In", I am asked to enter my account details. After entering these correctly, the dialog disappears and I am back at the previous screen without any message.
I have tried various combinations of signing out and in again, deleting %localappdata%.IdentityService, deleting %temp% and restarting my PC.
Everything looks fine in my Azure portal.
I am able to publish to Azure App Services using existing publish profiles.
Once in a while I get this error:
The output of that log is shown below:
02/28/2023 14:16:34 W. Europe Standard Time : Error : Attempt 1 to call 'v1.0/me', failed with an error: 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at HttpResponseMessage System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/28/2023 14:16:34 W. Europe Standard Time : Error : Retry count met, for 'v1.0/me' calls, giving up.
02/28/2023 14:16:34 W. Europe Standard Time : Error : Attempt 1 to call '/f8cdef31-a31e-4b4a-93e4-5f571e91255a/me?api-version=1.6', failed with an error: 'System.UnauthorizedAccessException: Unauthorized to access 'https://graph.windows.net/f8cdef31-a31e-4b4a-93e4-5f571e91255a/me?api-version=1.6'. Forbidden
at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/28/2023 14:17:24 W. Europe Standard Time : Error : Attempt 1 to call 'v1.0/organization/f8cdef31-a31e-4b4a-93e4-5f571e91255a', failed with an error: 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at HttpResponseMessage System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/28/2023 14:17:25 W. Europe Standard Time : Error : Attempt 2 to call 'v1.0/organization/f8cdef31-a31e-4b4a-93e4-5f571e91255a', failed with an error: 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at HttpResponseMessage System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/28/2023 14:17:27 W. Europe Standard Time : Error : Attempt 3 to call 'v1.0/organization/f8cdef31-a31e-4b4a-93e4-5f571e91255a', failed with an error: 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at HttpResponseMessage System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/28/2023 14:17:27 W. Europe Standard Time : Error : Retry count met, for 'v1.0/organization/f8cdef31-a31e-4b4a-93e4-5f571e91255a' calls, giving up.
02/28/2023 14:17:27 W. Europe Standard Time : Error : Failed getting tenant details preferred client exception 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at HttpResponseMessage System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)
at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)
at async Task<(string displayName, string defaultDomainName)> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.Graph.GraphClient+AbstractGraphClient.GetTenantDetailsAsync(GraphTokenRequestParameters tokenRequestParameters, CancellationToken cancellationToken)
at async Task<(string displayName, string defaultDomainName)> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.Graph.GraphClient.GetTenantDetailsAsync(GraphTokenRequestParameters tokenRequestParameters, CancellationToken cancellationToken)'
02/28/2023 14:17:27 W. Europe Standard Time : Error : Attempt 1 to call '/f8cdef31-a31e-4b4a-93e4-5f571e91255a/tenantDetails?api-version=1.6', failed with an error: 'System.UnauthorizedAccessException: Unauthorized to access 'https://graph.windows.net/f8cdef31-a31e-4b4a-93e4-5f571e91255a/tenantDetails?api-version=1.6'. Forbidden
at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)'
02/28/2023 14:17:27 W. Europe Standard Time : Error : Failed getting tenant details fallback exception 'System.UnauthorizedAccessException: Unauthorized to access 'https://graph.windows.net/f8cdef31-a31e-4b4a-93e4-5f571e91255a/tenantDetails?api-version=1.6'. Forbidden
at async Task<HttpResponseMessage> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.SendAsync(HttpRequestMessage request, ITelemetryOperation telemetryOp, CancellationToken cancellationToken)
at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)
at async Task<TResult> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.HttpClientWrapper.GetResponseAsync<TResult>(Func<IAadConfiguration, CancellationToken, Task<Uri>> hostProvider, Uri apiUri, GraphTokenRequestParameters authParameters, Func<HttpResponseMessage, Task<TResult>> transformation, ITelemetryOperation telemetryOp, int attemptCount, CancellationToken cancellationToken, string callerName)
at async Task<(string displayName, string defaultDomainName)> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.Graph.GraphClient+AbstractGraphClient.GetTenantDetailsAsync(GraphTokenRequestParameters tokenRequestParameters, CancellationToken cancellationToken)
at async Task<(string displayName, string defaultDomainName)> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.Graph.GraphClient.GetTenantDetailsAsync(GraphTokenRequestParameters tokenRequestParameters, CancellationToken cancellationToken)'
02/28/2023 14:17:27 W. Europe Standard Time : Error : Skipping tenant 'f8cdef31-a31e-4b4a-93e4-5f571e91255a' error getting friendly name: 'System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at async Task<(string displayName, string defaultDomainName)> Microsoft.Developer.IdentityService.AccountProvider.AADAccountProvider.Graph.GraphClient.GetTenantDetailsAsync(GraphTokenRequestParameters tokenRequestParameters, CancellationToken cancellationToken)
at async Task Microsoft.Developer.IdentityService.AccountProvider.AadAccountProviderNetworkServicesBase.GetTenantDetailsAsync(TenantInformation partialTenantInfo, AuthenticationInfo authInfo, bool promptIfNeeded, string queryParameters, AuthenticationFlowType authenticationFlowType, Dictionary<string, string> additionalAuthProperties, CancellationToken cancellationToken)
at async Task Microsoft.Developer.IdentityService.AccountProvider.AadAccountProviderService.TryGetTenantDetailsAsync(AuthenticationInfo authInfo, bool promptIfNeeded, string queryParameters, AuthenticationFlowType authenticationFlowType, Dictionary<string, string> additionalAuthProperties, List<TenantInformation> tenants, HashSet<MissingTenantInfo> missingTenants, CancellationToken cancellationToken)'
02/28/2023 14:18:09 W. Europe Standard Time : Error : Exception getting AAD Organization membership Error:'System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
at async Task<HttpResponseMessage> Microsoft.VisualStudio.Services.Common.VssHttpRetryMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at async Task<HttpResponseMessage> System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request)+Core(?)
at async Task<HttpResponseMessage> Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync(HttpRequestMessage message, HttpCompletionOption completionOption, object userState, CancellationToken cancellationToken)
at async Task<T> Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync<T>(HttpRequestMessage message, object userState, CancellationToken cancellationToken)
at async Task<ConnectionData> Microsoft.VisualStudio.Services.Location.Client.LocationHttpClient.GetConnectionDataAsync(ConnectOptions connectOptions, long lastChangeId, CancellationToken cancellationToken, object userState)
at async Task<ConnectionData> Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.GetConnectionDataAsync(ConnectOptions connectOptions, int lastChangeId, CancellationToken cancellationToken)
at async Task Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.ConnectAsync(ConnectOptions connectOptions, CancellationToken cancellationToken)
at async Task<VssConnection> Microsoft.Developer.IdentityService.AccountProvider.AadAccountProviderNetworkServicesBase.GetVssConnectionAsync(VssAadCredential aadCredential, CancellationToken cancellationToken)
at async Task<ImmutableArray<string>> Microsoft.Developer.IdentityService.AccountProvider.AadAccountProviderNetworkServicesBase.GetAADOrganizationInformationAsync(AuthenticationInfo authInfo, bool promptIfNeeded, string queryParameters, AuthenticationFlowType authenticationFlowType, Dictionary<string, string> additionalAuthProperties, CancellationToken cancellationToken) ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
at void System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at int System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(?)
at async ValueTask<int> System.Net.Security.SslStream.FillHandshakeBufferAsync<TIOAdapter>(TIOAdapter adapter, int minSize)+InternalFillHandshakeBufferAsync(?)
at async ValueTask<ProtocolToken> System.Net.Security.SslStream.ReceiveBlobAsync<TIOAdapter>(TIOAdapter adapter)
at async Task System.Net.Security.SslStream.ForceAuthenticationAsync<TIOAdapter>(TIOAdapter adapter, bool receiveFirst, byte[] reAuthenticationData, bool isApm)
at async ValueTask<SslStream> System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, bool async, Stream stream, CancellationToken cancellationToken) ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host.
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---', waiting '1' seconds to retry. On retry count '1'
02/28/2023 14:18:53 W. Europe Standard Time : Error : Exception getting AAD Organization membership Error:'System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
at async Task<HttpResponseMessage> Microsoft.VisualStudio.Services.Common.VssHttpRetryMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at async Task<HttpResponseMessage> System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request)+Core(?)
at async Task<HttpResponseMessage> Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync(HttpRequestMessage message, HttpCompletionOption completionOption, object userState, CancellationToken cancellationToken)
at async Task<T> Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync<T>(HttpRequestMessage message, object userState, CancellationToken cancellationToken)
at async Task<ConnectionData> Microsoft.VisualStudio.Services.Location.Client.LocationHttpClient.GetConnectionDataAsync(ConnectOptions connectOptions, long lastChangeId, CancellationToken cancellationToken, object userState)
at async Task<ConnectionData> Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.GetConnectionDataAsync(ConnectOptions connectOptions, int lastChangeId, CancellationToken cancellationToken)
at async Task Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.ConnectAsync(ConnectOptions connectOptions, CancellationToken cancellationToken)
at async Task<VssConnection> Microsoft.Developer.IdentityService.AccountProvider.AadAccountProviderNetworkServicesBase.GetVssConnectionAsync(VssAadCredential aadCredential, CancellationToken cancellationToken)
at async Task<ImmutableArray<string>> Microsoft.Developer.IdentityService.AccountProvider.AadAccountProviderNetworkServicesBase.GetAADOrganizationInformationAsync(AuthenticationInfo authInfo, bool promptIfNeeded, string queryParameters, AuthenticationFlowType authenticationFlowType, Dictionary<string, string> additionalAuthProperties, CancellationToken cancellationToken) ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
at void System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at int System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(?)
at async ValueTask<int> System.Net.Security.SslStream.FillHandshakeBufferAsync<TIOAdapter>(TIOAdapter adapter, int minSize)+InternalFillHandshakeBufferAsync(?)
at async ValueTask<ProtocolToken> System.Net.Security.SslStream.ReceiveBlobAsync<TIOAdapter>(TIOAdapter adapter)
at async Task System.Net.Security.SslStream.ForceAuthenticationAsync<TIOAdapter>(TIOAdapter adapter, bool receiveFirst, byte[] reAuthenticationData, bool isApm)
at async ValueTask<SslStream> System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, bool async, Stream stream, CancellationToken cancellationToken) ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host.
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---', waiting '2' seconds to retry. On retry count '2'
I have also noticed that when removing/adding my microsoft account in visual studio, it takes an unusually long time to readd.
I have also recently set up Microsoft 365 Business as an admin initially using the same microsoft account (I think?), which correlates with the timing of the visual studio issues.
Any help would be much appreciated!
I found this solution and for me it works.
https://blog.jongallant.com/2021/08/visual-studio-re-enter-credentials/
@Jan Fischer I've retagged your question to Visual Studio for the appropriate audience. If you don't get any traction, you may need to repost this on their developer community page.
In looking at the call stack, it definitely looks like the request to the tenant is being blocked with 400 error. Other the verifying the account settings (image below), then I would try removing your account from Visual Studio and adding it back.
I've been blocked with this before, where I couldn't access resources; unfortunately, I don't recall if it was this exact error. But what I did was removed my account from VS and removed any associated Windows Credentials and try to readd the accounts (personal and work) in Visual Studio.