I have used the ADAL.js for acquiring token for Azure Resources.
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.15/js/adal.min.js"></script>
I have written the following code in order to do so:
var endpoints = {
"https://management.core.windows.net": "https://management.core.windows.net"
};
var config = {
clientId: '634c7103-b43e-4384-b345-db0116058ac3',
endpoints: endpoints,
};
var authContext = new AuthenticationContext(config);
function login() {
authContext.popUp = true;
authContext.login();
authContext.handleWindowCallback();
};
function clickme() {
var user = authContext.getCachedUser();
console.log(user);
authContext.acquireToken('https://management.core.windows.net', function (error, token) {
console.log(error);
console.log(token);
});
};
Now when I have called clickme() after login, got the following error message: Token renewal operation failed due to timeout. Am I missing something ?
My final goal is to create a web application that can list all the subscription, resource group and vault corresponding to the user.
Please ensure that
handleWindowCallback
method is called when AAD sends the response to redirectUri. Whatever code is executed when the redirectUri page is loaded should ensure thathandlewindowcallback
method is called.Please try below code , it works fine on my side :
Please let me know if it helps.