Stackedit/static/oauth2/callback.html

37 lines
1017 B
HTML
Raw Normal View History

2017-08-06 14:04:00 +00:00
<!DOCTYPE html>
<html>
<body>
<script>
var state;
var accessToken;
2017-09-23 19:01:50 +00:00
var code;
2017-08-15 10:43:26 +00:00
var expiresIn;
2017-08-06 14:04:00 +00:00
function parse(search) {
(search || '').slice(1).split('&').forEach(function (param) {
var split = param.split('=');
var key = decodeURIComponent(split.shift());
var value = decodeURIComponent(split.join('='));
if (key === 'state') {
state = value;
} else if (key === 'access_token') {
accessToken = value;
2017-09-23 19:01:50 +00:00
} else if (key === 'code') {
code = value;
2017-08-15 10:43:26 +00:00
} else if (key === 'expires_in') {
expiresIn = value;
2017-08-06 14:04:00 +00:00
}
});
}
parse(location.search);
parse(location.hash);
var origin = location.protocol + '//' + location.host;
2017-08-15 10:43:26 +00:00
(window.opener || window.parent).postMessage({
2017-08-06 14:04:00 +00:00
state: state,
2017-08-15 10:43:26 +00:00
accessToken: accessToken,
2017-09-23 19:01:50 +00:00
code: code,
2017-08-15 10:43:26 +00:00
expiresIn: expiresIn
2017-08-06 14:04:00 +00:00
}, origin);
</script>
</body>
</html>