Google chrome extension 当我尝试将Chrome扩展从Chrome.identity.getAuthToken移植到launchWebAuthFlow时,是什么导致了这么多失败?
我希望我的扩展在Firefox和新的chromium Edge中工作。 它们不适用于chrome.identity.getAuthToken。 所以我要移植到Google chrome extension 当我尝试将Chrome扩展从Chrome.identity.getAuthToken移植到launchWebAuthFlow时,是什么导致了这么多失败?,google-chrome-extension,oauth-2.0,Google Chrome Extension,Oauth 2.0,我希望我的扩展在Firefox和新的chromium Edge中工作。 它们不适用于chrome.identity.getAuthToken。 所以我要移植到chrome.identity.launchWebAuthFlow。 Background.js代码如下: ``` const AUTH_URL = "https://accounts.google.com/o/oauth2/auth?client_id=971865119963-n9f0c5n0hga44jpds61ea4btfq608p
chrome.identity.launchWebAuthFlow
。
Background.js代码如下:
```
const AUTH_URL = "https://accounts.google.com/o/oauth2/auth?client_id=971865119963-n9f0c5n0hga44jpds61ea4btfq608pfh.apps.googleusercontent.com&response_type=token&redirect_uri=https%3A%2F%2Flnfajhkleofjochkapfbagfddgmpgble.chromiumapp.org&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fphotoslibrary%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fphotoslibrary.sharing";
background.getAccessToken = function() {
return new Promise((resolve, reject) => {
chrome.identity.launchWebAuthFlow({interactive: true, url: AUTH_URL}, function (response) {
if (response) resolve(response);
else {
console.log(chrome.runtime.lastError.message);
reject();
}
});
});
}
我已经在background.js
和弹出的browser\u action.js
中运行了这段代码。
它总是返回一个未定义的响应,
并发出失败消息:
Unchecked runtime.lastError: Authorization page could not be loaded.
或
事实上,在Chrome中,使用Chrome.identity.getAuthToken,这已经起到了作用
好了几年,sorta证明了我的开发者控制台oauth配置是正确的
五天来,我一直在跟踪stackOverflow中所有可能的线索,
结果一事无成。请帮忙
Unchecked runtime.lastError: Authorization page could not be loaded.
Error: redirect_uri_mismatch