-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
32 lines (29 loc) · 1.05 KB
/
index.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
<!DOCTYPE html>
<html>
<body>
<h1>Hello World</h1>
<p>This is for Okta redirect purpose</p>
</body>
<script>
//this is to retrieve authentication code from URL and store in sessionStorage.
const urlParams = new URLSearchParams(window.location.search);
authCode = urlParams.has('code') ? urlParams.get('code') : '';
console.log('URLauthcode: ' + authCode);
// Retrieve State set earlier and use it to redirect back to previous page.
var sState = '';
let sOktaTransactionStorage = window.sessionStorage.getItem("okta-transaction-storage");
if (sOktaTransactionStorage) {
try {
const oStorage = JSON.parse(sOktaTransactionStorage);
if (oStorage && oStorage.state) {
sState = oStorage.state || '';
console.log('State: ' + sState);
}
} catch (error) {
console.error("Error parsing sessionStorage:", error);
}
sessionStorage.setItem(sState, authCode);
window.location.replace(sState);
}
</script>
</html>