-
Notifications
You must be signed in to change notification settings - Fork 0
/
oauth-resp.html
42 lines (38 loc) · 1.4 KB
/
oauth-resp.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
31
32
33
34
35
36
37
38
39
40
41
42
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Authentication Success</title>
</head>
<body>
<script>
var run_on_load = function() {
var parent = window.parent || window.top,
origin = window.location.protocol + '//' + window.location.hostname,
message = 'error';
if (window.location.port !== '') {
origin = origin + ':' + window.location.port;
}
if (window.location.hash.indexOf('access_token') !== -1) {
message = '{"token":"' + window.location.hash.replace(/^.*access_token=([^&]+).*$/, '$1') +
'","expires_in":' + parseInt(window.location.hash.replace(/^.*expires_in=([^&]+).*$/, '$1')) + '}';
} else if (window.location.search.indexOf('code') !== -1) {
message = '{"code":"' + window.location.search.replace(/^.*code=([^&]+).*$/, '$1') + '"}';
}
try {
// Standards based browsers
parent.postMessage(message, origin);
} catch(e) {}
if (window === window.top) {
window.location = window.location.protocol + '//' + window.location.host + '/';
}
};
if (window.addEventListener) {
window.addEventListener("DOMContentLoaded", run_on_load);
} else {
run_on_load(); // IE 8
}
</script>
</body>
</html>