[英]Chrome Extension change url in the same popup
I am trying to write a chrome extension, and in it i need to open a new link for the Spotify web API authorisation. 我正在尝试编写一个Chrome扩展程序,并且在其中我需要打开一个新链接来授权Spotify Web API。 However, window.open() opens it in a new tab and my extension popup closes.
但是,window.open()在新选项卡中将其打开,并且我的扩展弹出窗口关闭。 Is there a way to open an url over the default_popup or at least keep it from closing automatically?
有没有办法打开default_popup上的网址,或者至少阻止它自动关闭?
Thanks 谢谢
Thanks to w0xx0m i got it to work. 多亏了w0xx0m,我才能够正常工作。 Turns out, i needed to use the Chrome identity API
chrome.identity.launchWebAuthFlow
. 原来,我需要使用Chrome身份API
chrome.identity.launchWebAuthFlow
。
In my case, i tried to authorize with Spotify on behalf of the user, and get the return url which contained the access token. 就我而言,我试图代表用户向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
.......
});
});`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.