Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.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 Chrome.identity.getAuthToken是否返回无效凭据?_Google Chrome_Google Chrome Extension_Google Oauth_Google Api Client - Fatal编程技术网

Google chrome Chrome.identity.getAuthToken是否返回无效凭据?

Google chrome Chrome.identity.getAuthToken是否返回无效凭据?,google-chrome,google-chrome-extension,google-oauth,google-api-client,Google Chrome,Google Chrome Extension,Google Oauth,Google Api Client,我已经学习了一些教程: 要让我的chrome扩展通过Google API项目的身份验证,请执行以下代码: chrome.identity.getAuthToken({ 'interactive': false }, function (token) { // Catch chrome error if user is not authorized. if (chrome.runtime.lastError) { $("#__sample_support_

我已经学习了一些教程:

要让我的chrome扩展通过Google API项目的身份验证,请执行以下代码:

chrome.identity.getAuthToken({ 'interactive': false }, function (token) {

    // Catch chrome error if user is not authorized.
    if (chrome.runtime.lastError) {

        $("#__sample_support_logarea").text(chrome.runtime.lastError.message);
        console.log('No token aquired');
        console.log(chrome.runtime.lastError.message);

        sampleSupport.log('No token aquired');
        sampleSupport.log(chrome.runtime.lastError.message);


    } else {
        console.log('Token acquired');
        console.log(token);
    }

});
始终返回:

OAuth2 request failed: Invalid credentials (credentials rejected by client).
这是我的manifest.json:

{
  "manifest_version": 2,

  "name": "Shopify Partners",
  "description": "Automate Proposal Creation",
  "version": "1.0",
  "background": {
    "scripts": [
      "background.js"
    ]
  },
  "content_scripts": [
    {
      "js": [ "jquery.min.js", "main.js" ],
      "matches": [ "http://*/*", "https://*/*" ]
    }
  ],
  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },
  "permissions": [
    "activeTab",
    "identity",
    "https://accounts.google.com/*",
    "https://www.googleapis.com/*"
  ],
  "oauth2": {
    "client_id": "..sr1t2ass4f9a0.apps.googleusercontent.com",
    "scopes": [
      "https://www.googleapis.com/auth/spreadsheets"
    ]
  },
  "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp8Cj7TI9toe9nK0Pw8FFk1hOlSCPUwJ/GUmWUgzyO3XBP2KoIFv+ISpOoPO++itYsDaXBgZzjk/EUeFMPUWbmuL6+lfs6orq39mMzQKLZEMV05bRaVVsj7gMtBGrsuOJm83Ugw+2tUVszH/yCzMFYNGqJe+ZaEPyUDVqeOfbZoo+JDleDveu0j+HTKDa6wVdDxndT+N86IEoPKCWfXdzMZ6+22ZTSPKYIvQbaHalqEQ9YAc80eHaL0eQNq/+aEv3oNWm2rbB8fy79koQKkZBuWJqgWmznWe6NzPkEpsiE+ilaUCKzWzFDFpiIC0A5Eq3KpWQdnQYDF1A2gmTh9vgkQIDAQAB",
  "content_security_policy": "script-src 'self' https://apis.google.com https://ajax.googleapis.com; object-src 'self'"
}
请注意,出于安全原因,我省略了完整的客户端id

我唯一怀疑的原因可能是,我正在chrome开发模式下运行一个未打包的扩展,其id类似于:gcnonhfkghlloailceidfmlmdeajlkl

在Api控制台中,当为客户端创建凭据时,我已指定相同的凭据:


因此,我怀疑作为一个未打包的扩展可能包含它。但是在Chrome应用商店中发布扩展是一个漫长的过程,当然不是这么简单的任务所期望的。

我认为您的扩展id已经更改。同样的事情也发生在我身上


为了解决这个问题,我再次创建了google
OAuth 2.0客户端ID
,它已经被修复。

API需要在web应用商店中进行真正的扩展,因为web应用商店创建了一个真正的子域,用于重定向身份验证。我真的不知道这是什么意思。