2017-06-02 63 views
0

我想寫一個Chrome擴展,並在其中我需要打開Spotify Web API授權的新鏈接。但是,window.open()在新標籤中打開它,並且我的擴展名彈出窗口關閉。有沒有辦法通過default_popup打開一個url,或者至少不讓它自動關閉?Chrome擴展更改網址在相同的彈出

謝謝

+0

使用chrome.identity API [Chrome擴展OAUTH與Spotify的API(// stackoverflow.com/a/38305120) – wOxxOm

+0

@wOxxOm謝謝,該訣竅。 – MarkwinVI

回答

0

感謝w0xx0m我得到它的工作。事實證明,我需要使用Chrome identity APIchrome.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 
      ....... 
     }); 
    });` 
相關問題