-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoauth-callback.html
More file actions
33 lines (31 loc) · 899 Bytes
/
oauth-callback.html
File metadata and controls
33 lines (31 loc) · 899 Bytes
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
<!DOCTYPE html>
<html>
<head>
<title>OAuth Callback</title>
<script>
// Extract the token from the URL fragment
const hash = window.location.hash.substring(1);
const params = new URLSearchParams(hash);
// Check if token exists
const token = params.get("access_token");
if (token) {
// Send the token back to the parent window
if (window.opener && !window.opener.closed) {
window.opener.postMessage({
token: token,
expiresIn: params.get("expires_in"),
username: params.get("username"),
}, window.location.origin);
}
// Close the popup
window.close();
} else {
// Show an error message if token is missing
document.body.innerHTML = "<p>Error: Unable to retrieve token. Please try again.</p>";
}
</script>
</head>
<body>
<p>Processing authentication...</p>
</body>
</html>