-
Notifications
You must be signed in to change notification settings - Fork 1
/
oauth-popup.html
30 lines (30 loc) · 1007 Bytes
/
oauth-popup.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Oauth2 callback window</title>
<style>*[hidden] { display: none; } </style>
</head>
<body>
<h1>Sending the authorization data to the application</h1>
<p id="general-error" hidden>
The window wasn't opened as a popup and therefore it can't pass the authorization information.<br/>
This is an error.
</p>
<script>
const messageTarget = (window.opener || window.parent || window.top);
const targetOrigin = messageTarget.origin;
if (!messageTarget || messageTarget === window || !messageTarget.postMessage) {
const elm = document.getElementById('general-error');
elm.removeAttribute('hidden');
} else {
const search = window.location.search.substr(1);
if (search) {
messageTarget.postMessage(search, targetOrigin);
} else {
messageTarget.postMessage(window.location.hash.substr(1), targetOrigin);
}
}
</script>
</body>
</html>