我正在开发一个浏览器扩展。下面的代码使用了chrome.identity.launchWebAuthFlow
应用程序接口,在一台机器上运行。我尝试使用浏览器的"Load Unpacked“特性将相同的代码加载到另一台机器上,但是现在回调的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();
});
}
);
});
发布于 2020-08-16 11:44:33
问题是一些javascript被添加到oauth页面,这会截获请求并阻止重定向响应被正确接收。
https://stackoverflow.com/questions/63430965
复制相似问题