Forum Discussion
Power BI Report Embed using JavaScript
The browser is blocking the request because you are getting data back from a domain that is not the same as your site. That's a good thing for security reasons. You'll want to execute that request outside of the browser. In my implementation, I have this piece running on an extremely basic Node server using express to expose it to the front end.
Thank you csjames010 !
Yes, I found out below code which uses ADAL.js, but my question is what should be the redirect_uri in my Azure AD app so that below code returns the id_token to ServiceNow Page and further we can access it for embed report javascript? Currently when I execute this code, it successfully generates the id_token in browser URL after login.
<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>
- csjames0106 years agoFrequent Visitor
Sorry - wish I could help more, there. I'm not really that familiar with the msft libraries. I've prototyped user owns and app owns data scenarios in my app, but both methods are just using POST requests on the auth endpoints on my backend server opposed to leveraging the libraries.