oauth验证后关闭窗口弹出窗口

我正在尝试在我的应用程序中包含某些第三方应用程序的oauth。基本上在按钮上单击“我从后端请求身份验证的URL”。然后,我使用window.open(url)打开一个新窗口。用户完成此过程后,我的弹出窗口将重定向到回调URL。

现在,我想在重定向到弹出网址后立即关闭弹出窗口。我该怎么办?

function connectToApp() {
    loginRequest()
        .then(function openNewWindow(res) {
            var url = res.data,width = 700,height = 500,left = (screen.width/2) - (width / 2),top = (screen.height/2) - (height / 2),params = 'modal=yes,alwaysRaised=yes,left=' + left + ',top=' + top + ',width=' + width + ',height=' + height;

            if(newWindow === null || newWindow.closed) {
                newWindow= window.open(url,'newWindow',params);
                newWindow.focus();
            } else {
                newWindow.focus();
            }                   
    })
};

完成身份验证后,我将重定向到回调URL到新窗口。我尝试使用window.postMessage,但不知道如何实现。

  1. 我要关闭新窗口。
  2. 我的应用程序如何知道用户已完成身份验证?
  3. 我不需要重定向到回调URL,因为我只想在身份验证完成后将应用程序中的视图从注销切换为登录。
zgyifei 回答:oauth验证后关闭窗口弹出窗口

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3113991.html

大家都在问