Advertisement
Guest User

Untitled

a guest
Sep 12th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <script type="text/javascript" src="https://env-92950.trial.cloud.microstrategy.com/MicroStrategyLibrary/javascript/embeddinglib.js"></script>
  7. <script type="text/javascript">
  8. var postData = {};
  9. postData.username = "yogi";
  10. postData.password = "weblogic";
  11. postData.loginMode = 1;
  12.  
  13. </script>
  14. </head>
  15. <body onload="load()">
  16.  
  17. <div id="mydossier" height="100%" width="100%"></div>
  18.  
  19.  
  20. <script type="text/javascript">
  21. var myDossier;
  22.  
  23. /* Minimal information necessary to authenticate with Guest(Anonymous) authentication */
  24. var postData = {
  25. loginMode: 1
  26. }
  27.  
  28.  
  29. function getXHRRequestPromise(url, body, method, contentType, desiredHeader) {
  30. return new Promise(function(resolve, reject) {
  31. var xhr = new XMLHttpRequest();
  32. xhr.open(method, url);
  33. xhr.setRequestHeader('Content-Type', 'application/json');
  34. xhr.setRequestHeader("Accept", "application/json");
  35. xhr.send(JSON.stringify(body));
  36.  
  37. xhr.onreadystatechange = function() {
  38. if (xhr.readyState === 2) {
  39. resolve(xhr.getResponseHeader(desiredHeader));
  40. } else {
  41. reject({
  42. status: this.status,
  43. statusText: xhr.statusText
  44. });
  45. }
  46. };
  47. });
  48. };
  49.  
  50.  
  51.  
  52. function load() {
  53. var container = document.getElementById("mydossier"),
  54. url = "https://env-92950.trial.cloud.microstrategy.com/MicroStrategyLibrary/app/19E3120C11E847D125D60080EFF5FD36/FCD0BEC011E8B5FE1F7C0080EFB57F21";
  55. microstrategy.dossier.create({
  56. url: url,
  57. enableCustomAuthentication: true,
  58. enableResponsive: true,
  59. customAuthenticationType: microstrategy.dossier.CustomAuthenticationType.AUTH_TOKEN,
  60. placeholder: container,
  61. getLoginToken: function() {
  62. return getXHRRequestPromise('https://env-92950.trial.cloud.microstrategy.com/MicroStrategyLibrary/api/auth/login', postData, 'POST','application/json', 'x-mstr-authToken').then(function(authToken){
  63. return authToken;
  64. });
  65. },
  66. })
  67. };
  68. </script>
  69.  
  70. </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement