Stackedit/static/oauth2/callback.html

33 lines
916 B
HTML
Raw Normal View History

2017-08-06 14:04:00 +00:00
<!DOCTYPE html>
<html>
<body>
<script>
var state;
var accessToken;
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-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,
expiresIn: expiresIn
2017-08-06 14:04:00 +00:00
}, origin);
</script>
</body>
</html>