Google chrome extension 如何区分chrome网上商店中的免费用户和付费的一次性免费应用程序
到目前为止,我已经采取了以下行动: 我在开发者控制台中有一个新项目: 并启用这些api: *Chrome网络商店APIGoogle chrome extension 如何区分chrome网上商店中的免费用户和付费的一次性免费应用程序,google-chrome-extension,google-api,chrome-web-store,Google Chrome Extension,Google Api,Chrome Web Store,到目前为止,我已经采取了以下行动: 我在开发者控制台中有一个新项目: 并启用这些api: *Chrome网络商店API Google+API BigQueryAPI Debuglet控制器API 谷歌云SQL 谷歌云存储 谷歌云存储JSON API 我猜我真的不需要所有的 在API和auth下的“凭据”中,我有“Chrome应用程序的客户端ID” 我获取了“客户端ID”并将其植入manifest.json文件中,如下所示: "oauth2": { "client_id":
- Google+API
- BigQueryAPI
- Debuglet控制器API
- 谷歌云SQL
- 谷歌云存储
- 谷歌云存储JSON API
"oauth2": {
"client_id": "blablablabla.apps.googleusercontent.com",
"scopes": [
"https://www.googleapis.com/auth/drive"
]
}
还有manifest.json中的chrome扩展权限:
"permissions": [
"http://*/*",
"https://*/*",
"tabs",
"cookies",
"management",
"notifications",
"contextMenus",
"management",
"storage",
"webRequest",
"webRequestBlocking",
"identity"
],
我在开发者控制台中有一个新项目:
不知道我是否需要
当我尝试执行此请求时:
chrome.identity.getAuthToken({ 'interactive': true }, function(token) {
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.onreadystatechange = function() {
if (req.readyState == 4) {
var license = JSON.parse(req.responseText);
if (license.accessLevel == "FULL") {
// paid
}
else {
// free
}
}
}
req.send();
});
我收到一个403(禁止)错误——“权限不足”
为了澄清,getAuthToken请求doe向我提供了令牌
我只想区分免费用户和付费用户。这样做很难:(并不是说这个答案是及时的,而是需要包含一个额外的范围,允许您获得api结果 该请求所需的范围是:
”https://www.googleapis.com/auth/chromewebstore.readonly“
有关如何授权和使用该api调用的更多信息,请访问: