chrome.identity.launchWebAuthFlow重定向URL未定义



我正在开发一个浏览器扩展。下面使用chrome.identity.launchWebAuthFlowAPI的代码在一台机器上工作。我试图使用浏览器的"加载"将相同的代码加载到另一台机器上;加载未包装的";特性,但现在回调的redirect参数是undefined,而不是预期的URL字符串值。这导致整个事情失败。我回到我原来的机器,使用相同的";加载未包装的";功能,现在它也不能在那台机器上工作。在此期间,此代码或服务器没有任何更改。发生了什么事?

authenticateButton.addEventListener("click", () => {
const redirectURL = encodeURIComponent(chrome.identity.getRedirectURL());
const clientId = encodeURIComponent("ff");
const authURL = `https://linksaver.io/oauth?client_id=${clientId}&redirect_uri=${redirectURL}`;
return chrome.identity.launchWebAuthFlow(
{
interactive: true,
url: authURL
},
redirect => {
const parsed = new URL(redirect);
const token = parsed.searchParams.get("token");
chrome.storage.local.set({ token }, () => {
showLogout();
});
}
);
});

问题是在oauth页面中添加了一些javascript,这些javascript拦截了请求并阻止了重定向响应的正确接收。

最新更新