-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample-charis-api-verify.html
54 lines (51 loc) · 1.54 KB
/
example-charis-api-verify.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
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/core.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/md5.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/enc-base64.min.js"></script>
<style type="text/css">
.item {
margin: 10px 0;
}
label {
font-weight: bold;
}
.result {
white-space: pre-wrap
}
</style>
</head>
<body>
<h1>Response</h1>
<div id="token" class="item"><label>Token: </label><div class="result"></div></div>
<div id="response" class="item"><label>Reponse: </label><div class="result"></div></div>
<script type="text/javascript">
$(document.body).ready(function () {
var endpoint = 'https://api.hicharis.net'
var client = {
id: '__CLIENT_ID__',
secret: '__CLIENT_SECRET__'
}
var ts = Date.now()
var secret = CryptoJS.MD5(client.secret + ts)
var token = CryptoJS.enc.Base64.stringify(
CryptoJS.enc.Utf8.parse([client.id, secret, ts].join(':'))
)
// request
$.ajax({
url: endpoint + '/api/verify',
headers: {
Authorization: ['Basic', token].join(' ')
},
json: true,
success: function (res) {
// debug
$('#token div').text(token)
$('#response div').text(JSON.stringify(res, null, 2))
}
})
})
</script>
</body>
</html>