I'm trying to embed Power BI Reports(User Owns Data) into ServiceNow Portal which only supports JavaScript. Hence, I've created the Azure AD App using Service Principal and written below code using node.js to get the access token.
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.14/js/adal.min.js"></script>
<body>
<a href="#" onclick="login();">login</a>
<a href="#" onclick="getToken()">access token</a>
</body>
<script type="text/javascript">
var configOptions = {
tenant: <tenantid>, // Optional by default, it sends common
clientId: <clientid>,
redirectUri: "https://login.live.com/oauth20_desktop.srf",
postLogoutRedirectUri: window.location.origin,
}
window.authContext = new AuthenticationContext(configOptions);
var isCallback = authContext.isCallback(window.location.hash);
authContext.handleWindowCallback();
function getToken(){
authContext.acquireToken("https://graph.microsoft.com",function(error, token){
console.log(error);
console.log(token);
})
}
function login(){
authContext.login();
}
</script>
Question -
When I execute the above code, I get id_token in browser URL. How can I access it for further embed process? What should be the redirect_uri
of the Azure AD app so that we get the token in code rather than the browser URL?
Thank you!