0

我尝试使用 chorome.identity 对我的应用程序进行身份验证,但似乎 NWJS 无法加载 chrome://chrome-signin/?access_point=6&reason=0 上 chrome 提供的登录页面。我的 package.json 是这样的:

 "permissions": ["tabs", "identity", "storage", "https://www.googleapis.com/*",
        "https://*.googleusercontent.com/*",
        "https://ssl.gstatic.com/",
        "https://www.googleapis.com/",
        "https://accounts.google.com/",
        "chrome://chrome-signin/?access_point=6&reason=0"],

    "oauth2": {
        "client_id": "xxxxxx.apps.googleusercontent.com",
        "scopes": [
            "https://www.googleapis.com/auth/drive"
        ]
    },
    "key": "MIIBIjANBxxxxxxx"

这是我的代码:

 chrome.identity.getAuthToken({'interactive': true}, function (token) {
            if (chrome.runtime.lastError) {
                console.log(chrome.runtime.lastError);
                return;
            }

            console.log('Tokennya adalah', token);
        });

我写的代码有错吗?

4

1 回答 1

0

大多数情况下,您的 oauth2client_id与扩展程序的包 ID 不匹配。为 chrome 应用程序生成 oauth2 令牌时,它会在您使用清单上传初始应用程序后询问您的应用程序的网上商店 ID。检查它是否与加载到 chrome 进行开发的扩展相同。如果没有,请提供本地扩展名而不是网上商店 ID。并在清单中使用该 client_id 进行开发。稍后将其更改为要发布的 webstore url id。
并且在权限下不需要“chrome://chrome-signin/?access_point=6&reason=0” url。

于 2016-12-01T14:30:37.793 回答