访问Chrome Web Store许可API时出现后端错误500

JSl*_*ain 6 google-chrome-extension chrome-web-store

我正在尝试进行chrome扩展,它将有一个免费试用版。按照此处的文档操作,首先要做的就是启用Chrome Identity API。据我所知,没有这样的事情...

无论如何...我已经完成了所有其他步骤,最终出现500错误。

这是我所做的一部分。当然,我更改了所有ID,键,令牌等的值。

manifest.json

    {
      "name": "The name of my app",
      "version": "1.0.9",
      "key": "my_very_long_key",
      "description": "A description",
      "manifest_version": 2,
      "permissions": [ "activeTab", "storage", "declarativeContent", "identity", "https://www.googleapis.com/" ],
      "oauth2": {
        "client_id": "the_client_id_i_setup_in_Credentials_oauth2_section.apps.googleusercontent.com",
        "scopes": [
          "https://www.googleapis.com/auth/chromewebstore.readonly"
        ]
      },
    // other stuff...
Run Code Online (Sandbox Code Playgroud)

chrome.identity.getAuthToken({
  'interactive': true
}, (token) => {
  console.log("Token: %o", token);
  console.log("chrome.runtime.id: %o", chrome.runtime.id);

  var CWS_LICENSE_API_URL = 'https://www.googleapis.com/chromewebstore/v1.1/userlicenses/';
  var req = new XMLHttpRequest();
  req.open('GET', CWS_LICENSE_API_URL + chrome.runtime.id);
  req.setRequestHeader('Authorization', 'Bearer ' + token);
  req.setRequestHeader('Content-Type', 'application/json');

  req.onreadystatechange = () => {
    if (req.readyState == 4) {
      var license = JSON.parse(req.responseText);
      console.log(license);
    }
  }
  req.send();
});
Run Code Online (Sandbox Code Playgroud)

这是输出示例。

Token: "ya29.GlzqBp1FaFegsgm.oihohjbrbznghdfgmgighnzxfvxz3ve5G8GQ4VxZ653FqBa8aqq-JXil-VS5IGeknneZ6KnKbyknw-gXw"
chrome.runtime.id: "asdflhlkrfhuilerdfb"

Object
    error:
        code: 500
        errors: Array(1)
            0:
                domain: "global"
                message: "Backend Error"
                reason: "backendError"
                __proto__: Object
            length: 1
            __proto__: Array(0)
        message: "Backend Error"
        __proto__: Object
    __proto__: Object
Run Code Online (Sandbox Code Playgroud)

因此,我能够获得访问令牌,但是随后使用它调用API似乎没有任何结果。

Dra*_*ter 1

重新打开的错误:https ://issuetracker.google.com/issues/140188619

如果您有同样的问题,请在 issuestracker.google.com 上加注星标以加快 Google 速度)

更新:

问题已被 Google 修复! https://bugs.chromium.org/p/chromium/issues/detail?id=940478#c18