-
Notifications
You must be signed in to change notification settings - Fork 13
/
1_2_Guest_With_MultiAuth.html
60 lines (54 loc) · 2.31 KB
/
1_2_Guest_With_MultiAuth.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="https://demo.microstrategy.com/MicroStrategyLibraryInsights/javascript/embeddinglib.js"></script>
<!-- This is for the jsfiddle button. You don't need it in your application. -->
<script type="text/javascript" src="js/jsfiddle.js"></script>
</head>
<body>
<div>This example shows guest authentication with multiple authentication modes enabled. </div>
<div id="mydossier"></div>
<script type="text/javascript">
var baseURL = "https://demo.microstrategy.com/MicroStrategyLibraryInsights";
var projectId = "EC70648611E7A2F962E90080EFD58751";
var dossierId = "837B57D711E941BF000000806FA1298F";
function login() {
var options = {
method: 'POST',
credentials: 'include', // Including cookie
mode: 'cors', // Setting as cors mode for cross origin
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
loginMode: 8 // Login as guest user.
})
};
return fetch(baseURL + '/api/auth/login', options)
.then(function (response) {
if (response.ok) {
return response.headers.get('x-mstr-authToken');
} else {
response.json().then(function(json) {
console.log(json);
});
}
}).catch(function (error) {
console.log(error);
});
}
document.addEventListener("DOMContentLoaded", function(){
var placeHolderDiv = document.getElementById("mydossier");
var dossierUrl = baseURL +'/app/'+ projectId + '/' + dossierId;
microstrategy.dossier.create({
placeholder: placeHolderDiv,
url: dossierUrl,
enableCustomAuthentication: true,
enableResponsive: true,
customAuthenticationType: microstrategy.dossier.CustomAuthenticationType.AUTH_TOKEN,
getLoginToken: login
});
});
</script>
</body>
</html>