Google Login/Signin Yandex Android 扩展

Google Login/Signin on Yandex Android extension

我正在尝试 运行 我的桌面 chrome 在 Android 上的扩展,所以我尝试 运行 在我的 phone 上的 Yandex 浏览器中安装它.它 运行 没问题,除了 google 登录。(在桌面 Chrome 和桌面 Yandex 上一切正常)。 此代码由后台脚本调用:

var url = 'https://accounts.google.com/o/oauth2/auth' +
    '?client_id=' + clientId +
    '&response_type=id_token' +
    '&access_type=offline' +
    '&redirect_uri=' + redirectUri +
    '&scope=' + scopes;

getIdToken: function (message) {
    const _this = this;
    var idToken = "";
    chrome.identity.launchWebAuthFlow(
        {
            'url': url,
            'interactive': true
        },

    function (redirectedTo) {
        console.log("[2]auth-manager called: "+redirectedTo);
        if (chrome.runtime.lastError) {
            // Example: Authorization page could not be loaded.
            console.log("lastError: "+chrome.runtime.lastError.message);
        }
        else {
            var response = redirectedTo.split('#', 2)[1];
            // Example: id_token=<YOUR_BELOVED_ID_TOKEN>&authuser=0&hd=<SOME.DOMAIN.PL>&session_state=<SESSION_SATE>&prompt=<PROMPT>
            idToken = (response.split('&')[0]).split('=', 2)[1];
            console.log("auth-manager id token", idToken);
            if (message != undefined) {
                message.data.google_id_token = idToken;
                cloudWebSocket.sendMessage(JSON.stringify(message));
                _this.isLogged = true;
                closePopup();
                alert('login successful');
            }
        }
    }
);

}

当我调用这个函数时,redirectedTo 是未定义的,我得到一个 chrome.runtime.lastError.message:"canceled"。就是这样。

我使用与桌面应用程序完全相同的清单,具有相同的 clientId、redirectUri 和范围。 我无法弄清楚,是什么导致了这个问题? 如果有另一种方法可以执行 google 登录而不会出现此问题,它也会有所帮助。

查看 Web Extensions API ...特别是平台支持 table。

尽管如此,在服务器端启动 oAuth2 流程应该是可能的。