ManagedIdentityApplication.AcquireTokenForManagedIdentity("api://AzureADTokenExchange") giving error in local machine.

Anonymous
2024-05-10T11:41:44.0866667+00:00

Hi,

I am implementing the "Federated Identity Credential" along with User Managed identity in .net core 3.1 web api.

Getting the error code: "managed_identity_unreachable_network" with error message "A socket operation was attempted to an unreachable network." in local machine in visual studio. Please suggest the solution for the below code.

IManagedIdentityApplication mi = ManagedIdentityApplicationBuilder.Create(ManagedIdentityId.WithUserAssignedClientId(userAssignedMSI)).Build();
AuthenticationResult assertion= await mi.AcquireTokenForManagedIdentity("api://AzureADTokenExchange/.default").ExecuteAsync().ConfigureAwait(false);

Thank you,

Siva

Developer technologies | ASP.NET | ASP.NET Core
Microsoft Security | Active Directory Federation Services
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 82,606 Reputation points Volunteer Moderator
    2024-05-15T15:23:07.7266667+00:00

    The url you pass to AcquireTokenForManagedIdentity() is not valid.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.