I managed to get a similar script to work, starting with a sample of WebApp and WebApi using Azure AD and OpenID Connect.
Calling a web API in a web application using Azure AD and OpenID Connect
The sample provides a single sign for users in the web application and delegates the user ID from the web application to the api web application. He did this by extracting the carrier token into the web application controller and using it to call the web api. We can easily use the same bearer token to make an ajax javascript call by putting the bearer token in the authorization header:
//jQuery example settings.headers = { 'Authorization': 'Bearer ' + bearerToken, };
I was able to get this to work without adal.js liberary. Kors is still needed to make an ajax call in the cross domain.
source share