I’m trying to make calls to some of our internal apis from the an umbraco site but I am having trouble with the authentication. The apis have been secured with azure ad and the umbraco site has been given a client id and some roles which will allow it to call the app.
When I try to implement the following code in the program file:
builder.Services
.AddMicrosoftIdentityWebAppAuthentication(builder.Config, "ApiSettings:AzureAD")
.EnableTokenAcquisitionToCallDownstreamApi()
.AddInMemoryTokenCaches();
The site throws an error:
TypeLoadException: Could not load type ‘Microsoft.Identity.Web.MicrosoftIdentityOptions’ from assembly ‘Microsoft.Identity.Web, Version=3.2.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae’.
Unknown location
ReflectionTypeLoadException: Could not load all types from “Umbraco.Cloud.Identity.Cms, Version=13.0.1.0, Culture=neutral, PublicKeyToken=null” due to LoaderExceptions, skipping:
. System.TypeLoadException on Microsoft.Identity.Web.MicrosoftIdentityOptions: Could not load type ‘Microsoft.Identity.Web.MicrosoftIdentityOptions’ from assembly ‘Microsoft.Identity.Web, Version=3.2.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae’.
Does anyone know how to implement this so I can generate a token when making my http client request?
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/114748-enable-azure-ad-token-acquisition-for-downstream-calls