admin管理员组文章数量:1309940
I'm creating a web extension on Firefox using React
When I click on a button, a callback is called:
browser.runtime.sendMessage({ type: "auth", url: "url" })
.then((response) => {
console.log("Response:", response);
})
.catch((error) => {
console.error("Error:", error);
});
And, the background script is listening and indeed receives the message:
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.type === "auth") {
browser.identity.launchWebAuthFlow({ url: message.url, interactive:true })
.then((responseUrl) => {
console.log("callback!")
sendResponse({ success: true, url: responseUrl });
})
.catch((error) => {
sendResponse({ success: false, error: error.message });
});
return true;
}
});
The OAuth call is going fine, the callback is called and the log "callback!" can be seen. But the message is never received back on React side
Here is my manifest:
{
"manifest_version": 2,
"name": "Open Link Extension",
"version": "1.0",
"description": "An extension that opens a link when a button is clicked.",
"permissions": [
"tabs",
"identity",
"activeTab",
"webRequest",
"<all_urls>",
"cookies"
],
"browser_action": {
"default_popup": "html/popup.html"
},
"background": {
"scripts": [
"src/background.js"
],
"persistent": false
},
"icons": {
"48": "icon.png"
}
}
Thanks for your help!
本文标签: javascriptFirefox extension launchWebAuthFlow not able to use sendResponseStack Overflow
版权声明:本文标题:javascript - Firefox extension: launchWebAuthFlow not able to use sendResponse - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741845768a2400769.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论