【问题标题】:Chrome Extension change url in the same popupChrome 扩展在同一个弹出窗口中更改 url
【发布时间】:2017-11-04 04:18:33
【问题描述】:

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

谢谢

【问题讨论】:

标签: javascript google-chrome-extension


【解决方案1】:

感谢 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
            .......
        });
   });`

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-27
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-19
    • 1970-01-01
    相关资源
    最近更新 更多