Chrome扩展程序在同一弹出窗口中更改网址

时间:2017-06-02 17:15:59

标签: javascript google-chrome-extension

我正在尝试编写chrome扩展,在其中我需要为Spotify Web API授权打开一个新链接。但是,window.open()在新选项卡中打开它,我的扩展弹出窗口关闭。有没有办法在default_popup上打开一个url或者至少让它自动关闭?

由于

1 个答案:

答案 0 :(得分:0)

感谢w0xx0m,我得到了它的工作。事实证明,我需要使用Chrome identity API chrome.identity.launchWebAuthFlow

在我的情况下,我尝试代表用户使用Spotify进行授权,并获取包含访问令牌的返回URL。

     chrome.identity.launchWebAuthFlow({
        url : THE_AUTHORIZATION_URL,
       //If interactive is set to false, the logon screen won't show up
        interactive : true},

        function(data){
            //the 'data' contains the return URL
            .......
        });
   });`
相关问题