mirror of
https://github.com/System-End/Team_Website.git
synced 2026-04-20 00:25:24 +00:00
50 lines
2 KiB
HTML
50 lines
2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Authorization Callback</title>
|
|
<script>
|
|
// Parse the authorization code from the URL
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const code = urlParams.get("code");
|
|
|
|
// Exchange the authorization code for an access token
|
|
fetch(
|
|
"https://login.microsoftonline.com/common/oauth2/v2.0/token",
|
|
{
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
},
|
|
body: new URLSearchParams({
|
|
client_id: "c91a3691-c800-4aed-9e85-1a2c896327de",
|
|
scope: "openid offline_access Files.ReadWrite.All",
|
|
code: code,
|
|
redirect_uri:
|
|
"http://localhost:5500/Pages/Callback.html",
|
|
grant_type: "authorization_code",
|
|
client_secret: "ddba6e4e-62b1-4a13-b165-08b00ef6723f",
|
|
}),
|
|
}
|
|
)
|
|
.then((response) => response.json())
|
|
.then((data) => {
|
|
// Save the access token and optionally the refresh token in the parent window
|
|
window.opener.postMessage(
|
|
{
|
|
accessToken: data.access_token,
|
|
refreshToken: data.refresh_token,
|
|
},
|
|
"http://localhost:5500"
|
|
);
|
|
// Close the callback window
|
|
window.close();
|
|
})
|
|
.catch((error) => console.error("Error:", error));
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<p>Authorization successful. You can close this window.</p>
|
|
</body>
|
|
</html>
|