2024-03-28 17:07:30 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
2024-03-28 17:02:52 +00:00
|
|
|
<title>Sending data...</title>
|
2024-03-28 17:07:30 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2024-03-29 11:54:15 +00:00
|
|
|
<p>Sending data...</p>
|
2024-03-28 17:07:30 +00:00
|
|
|
|
|
|
|
<script>
|
2024-03-29 11:02:22 +00:00
|
|
|
function oauth() {
|
2024-03-31 12:49:09 +01:00
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
2024-03-28 17:07:30 +00:00
|
|
|
|
2024-03-29 11:02:22 +00:00
|
|
|
// Get URL parameters
|
2024-04-02 16:57:19 +01:00
|
|
|
if (urlParams.has('client_id')) {
|
|
|
|
var client_id = urlParams.get('client_id');
|
|
|
|
var redirect_uri = urlParams.get('redirect_uri');
|
|
|
|
var response_type = urlParams.get('response_type');
|
|
|
|
} else {
|
|
|
|
window.location.replace("/dashboard");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (urlParams.has('state')) {
|
|
|
|
var state = urlParams.get('state');
|
|
|
|
}
|
2024-03-31 12:49:09 +01:00
|
|
|
|
|
|
|
if (urlParams.has('code_challenge')) {
|
|
|
|
code = urlParams.get('code_challenge');
|
|
|
|
codemethod = urlParams.get('code_challenge_method');
|
|
|
|
} else {
|
|
|
|
code = "none"
|
|
|
|
codemethod = "none"
|
|
|
|
}
|
2024-03-28 17:07:30 +00:00
|
|
|
|
2024-03-29 11:02:22 +00:00
|
|
|
// Get DONOTSHARE-secretkey from localStorage
|
|
|
|
var secret_key = localStorage.getItem("DONOTSHARE-secretkey");
|
2024-03-28 17:07:30 +00:00
|
|
|
|
2024-03-29 11:02:22 +00:00
|
|
|
// Create data object to send
|
|
|
|
var data = {
|
|
|
|
appId: client_id,
|
2024-03-31 12:49:09 +01:00
|
|
|
secretKey: secret_key,
|
|
|
|
code: code,
|
|
|
|
codemethod: codemethod
|
2024-03-29 11:02:22 +00:00
|
|
|
};
|
2024-03-28 17:07:30 +00:00
|
|
|
|
2024-03-29 11:02:22 +00:00
|
|
|
// 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 => {
|
2024-03-28 18:32:48 +00:00
|
|
|
async function doStuff() {
|
2024-03-29 11:02:22 +00:00
|
|
|
let code = await response.text()
|
|
|
|
console.log(code)
|
2024-03-29 11:54:15 +00:00
|
|
|
window.location.replace(redirect_uri + "?code=" + code + "&state=" + state)
|
2024-03-28 18:32:48 +00:00
|
|
|
}
|
|
|
|
doStuff()
|
2024-03-29 11:02:22 +00:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
alert("Error sending data: " + error.message);
|
|
|
|
});
|
|
|
|
}
|
2024-03-29 11:54:15 +00:00
|
|
|
oauth()
|
2024-03-28 17:07:30 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|