-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallback.html
More file actions
30 lines (28 loc) · 919 Bytes
/
callback.html
File metadata and controls
30 lines (28 loc) · 919 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
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
function onOAuthCallback() {
var authInfo = getOAuthInfoFromUrl();
var token = authInfo["access_token"];
window.opener.onAuthenticated(token);
window.close();
}
function getOAuthInfoFromUrl() {
if (window.location.hash) {
var authResponse = window.location.hash.substring(1);
var authInfo = JSON.parse(
'{"' + authResponse.replace(/&/g, '","').replace(/=/g, '":"') + '"}',
function(key, value) { return key === "" ? value : decodeURIComponent(value); });
return authInfo;
} else {
alert("An error occurred while getting access token");
}
}
onOAuthCallback();
</script>
</body>
</html>