EDIT: I know some sites are using this function. How does they make it work, are they passing something from the popupwindow?
ORIGINAL: I'm working on a pass-through experience for following Spotify playlists. The user clicks follow and opens this function, which is then redirected to my wordpress site inside the popup window. I'm using the wordpress rest api to return a json access token. The problem is that I doesn't seem to get the json object back to the main window. Is this possible?
function o(t) {
var client = "xyz123", redirect = "https://wordpress/wp-json/plugin/v1/spotify/token/";
var i,
o = (i = ["playlist-modify-public"], "https://accounts.spotify.com/authorize?client_id=" + e + "&redirect_uri=" + encodeURIComponent(n) + "&scope=" + encodeURIComponent(i.join(" ")) + "&response_type=code"),
r = screen.width / 2 - 210,
a = screen.height / 2 - 285;
window.addEventListener("message", (function e(n) {
var i = JSON.parse(n.data);
(t(i.token), window.removeEventListener("message", e))
})),
window.open(o, "Spotify", "menubar=no,location=no,resizable=no,scrollbars=no,status=no, width=420, height=570, top=" + a + ", left=" + r)
}