-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
30 lines (30 loc) · 1.04 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
<!DOCTYPE html>
<html lang='en'>
<body>
<!--keycloak.js form keycloak-->
<script src='http://localhost:8180/auth/js/keycloak.js'></script>
<script type='text/javascript'>
'use strict'
const kongUrl = 'http://localhost:8000/demo/data'
const keycloak = Keycloak('keycloak.json')
keycloak.init({ onLoad: 'login-required' })
.error(function () { alert('error') })
.success(function (authenticated) {
let req = new XMLHttpRequest()
req.open('GET', kongUrl, true)
req.setRequestHeader('Accept', 'application/json')
req.setRequestHeader('Authorization', 'Bearer ' + keycloak.token)
req.onreadystatechange = function () {
if (req.readyState === 4) {
if (req.status === 200) {
alert('Response: ' + req.responseText)
} else {
alert('Request returned: ' + req.status)
}
}
}
req.send()
})
</script>
</body>
</html>