Reputation: 85
I want to generate an access token and embed token of the azure active directory from my web app using javascript. I tried to generate token by calling REST-API using ajax but I faced CORS issue. Then I tried using ADAL and MSAL but nothing work. How can I generate a token in my web app programmatically?
Upvotes: 1
Views: 584
Reputation: 7483
You could use ADAL/MSAL to integrate AAD in javascript. If using the client credentials flow that is not supported in javascript, you will get the CORS error.
There are samples to acquire access token:
Use ADAL for JS with implicit grant flow: https://stackoverflow.com/a/38319300/13308381
Use MSAL.js 1.0 with implicit grant flow: https://learn.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-javascript-spa
Use MSAL.js 2.0 with authorization code flow:https://learn.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-javascript-auth-code
Upvotes: 3