-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth-start.html
44 lines (40 loc) · 1.49 KB
/
auth-start.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
<html>
<head>
<title>Authentication</title>
</head>
<body>
<script src="https://statics.teams.microsoft.com/sdk/v1.0/js/MicrosoftTeams.min.js"></script>
<script src="adal.js"></script>
<script src="auth-config.js"></script>
<script type="text/javascript">
microsoftTeams.initialize();
// Parse query parameters
let queryParams = {};
location.search.substr(1).split("&").forEach(function(item) {
let s = item.split("="),
k = s[0],
v = s[1] && decodeURIComponent(s[1]);
queryParams[k] = v;
});
let upn = queryParams["upn"];
if (upn) {
config.extraQueryParameters = "scope=openid+profile&login_hint=" + encodeURIComponent(upn);
} else {
config.extraQueryParameters = "scope=openid+profile";
}
// Use a custom displayCall function to add extra query parameters to the url before navigating to it
config.displayCall = function (urlNavigate) {
if (urlNavigate) {
if (config.extraQueryParameters) {
urlNavigate += "&" + config.extraQueryParameters;
}
window.location.replace(urlNavigate);
}
}
console.log("extraQueryParameters: " + config.extraQueryParameters);
console.log("Starting login flow");
let authContext = new AuthenticationContext(config);
authContext.login();
</script>
</body>
</html>