Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome extension 当我尝试将Chrome扩展从Chrome.identity.getAuthToken移植到launchWebAuthFlow时,是什么导致了这么多失败?_Google Chrome Extension_Oauth 2.0 - Fatal编程技术网

Google chrome extension 当我尝试将Chrome扩展从Chrome.identity.getAuthToken移植到launchWebAuthFlow时,是什么导致了这么多失败?

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

我希望我的扩展在Firefox和新的chromium Edge中工作。 它们不适用于chrome.identity.getAuthToken。 所以我要移植到
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