访问 Chrome 网上应用店许可 API 时出现后端错误 500



我正在尝试制作一个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...

法典

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();
});

下面是一个输出示例。

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

所以我能够获得访问令牌,但是使用它调用 API 似乎不会产生任何结果。

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

请将其星标在 issuetracker.google.com 上,如果您有相同的问题以加快Google的速度)

更新:

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

最新更新