54 lines
1.5 KiB
HTML
54 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Sending data...</title>
|
|
</head>
|
|
<body>
|
|
<h1>Sending data...</h1>
|
|
|
|
<script>
|
|
// Function to parse URL parameters
|
|
function getUrlParameter(name) {
|
|
name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]');
|
|
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
|
|
var results = regex.exec(location.search);
|
|
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
|
};
|
|
|
|
// Get URL parameters
|
|
var client_id = getUrlParameter('client_id');
|
|
var redirect_uri = getUrlParameter('redirect_uri');
|
|
var response_type = getUrlParameter('response_type');
|
|
var state = getUrlParameter('state');
|
|
|
|
// Get DONOTSHARE-secretkey from localStorage
|
|
var secret_key = localStorage.getItem("DONOTSHARE-secretkey");
|
|
|
|
// Create data object to send
|
|
var data = {
|
|
client_id: client_id,
|
|
secretKey: secret_key,
|
|
state: state
|
|
};
|
|
|
|
// Send data to example.org using POST request
|
|
fetch("https://auth.hectabit.org/api/auth", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify(data)
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
window.location.replace(redirect_uri + "?code=" + response + "&state=" + state)
|
|
})
|
|
.catch(error => {
|
|
alert("Error sending data: " + error.message);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|