Код: Выделить всё
Project.Tests.IntegrationTests.MetadataTests.RouteMetadataTests. Error: System.InvalidOperationException: Failed to authenticate test user ---> Microsoft.Identity.Client.MsalServiceException: AADSTS900144: The request body must contain the following parameter: 'resource'. Trace ID: 5ae18229-6cd8-4962-b439-95cfb1630200 Correlation ID: f7e1941b-8f93-47df-ad5e-301db1f18edb Timestamp: 2025-06-08 14:14:39Z.
< /code>
private async Task AuthenticateAsync(string clientId,
string authority,
string username,
string password)
{
IPublicClientApplication app = PublicClientApplicationBuilder
.Create(clientId)
.WithExperimentalFeatures()
.WithOidcAuthority(authority)
.WithRedirectUri("https://localhost")
.Build();
try
{
string[] scopes = new string[]
{
//$"api:///.default",
"User.Read"
//"openid",
//"offline_access",
//"profile"
};
AuthenticationResult authResult = await app.AcquireTokenByUsernamePassword(scopes,
username,
password)
.ExecuteAsync();
if (authResult != null)
{
_client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
}
}
catch (MsalException ex)
{
throw new InvalidOperationException("Failed to authenticate test user", ex);
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... ce-missing