【发布时间】:2014-06-18 13:52:55
【问题描述】:
我正在使用Google Play Android Developer API 到服务器到服务器检查我们用户订阅的订阅状态,但在成功授权并要求现有订阅后,我收到 401 响应,并显示以下消息“当前用户没有足够的权限执行要求的操作”。 访问https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=XXXXXX 我可以看到我确实有请求的范围(https://www.googleapis.com/auth/androidpublisher),但我每次仍然得到相同的响应。 其他人有同样的问题吗?
编辑:我已经看到了 Explore API 应用程序的作用,它在请求的查询字符串中添加了键,但我没有那个值。在控制台中,我创建了一个服务帐户客户端 ID,它有一个客户端 ID、电子邮件地址和一个私钥,但没有显然 Explore API 使用的 API 密钥。
编辑编号。 2:我已将服务帐户生成的电子邮件添加到 Google Play Developer Console 和 Google Wallet 控制台,但我仍然无法访问。我正在使用 nodejs 和 google-oauth-jwt,因为谷歌没有为 nodejs 提供库。
这是我用来发出请求的代码:
var request = require('google-oauth-jwt').requestWithJWT();
function makeReq() {
request({
url: 'https://www.googleapis.com/androidpublisher/v1.1/applications/{packageName}/subscriptions/{subscriptionId}/purchases/{purchaseToken}',
jwt: {
// use the email address of the service account, as seen in the API console
email: 'blahblahtrutjtrutj@developer.gserviceaccount.com',
// use the PEM file we generated from the downloaded key
keyFile: 'purchases-test.pem',
// specify the scopes you wish to access
scopes: ['https://www.googleapis.com/auth/androidpublisher']
}
}, function (err, res, body) {
if (err) {
console.log(err);
} else {
console.log("BODY IS ------------------------------------------");
console.log(JSON.parse(body));
}
});
}
【问题讨论】:
标签: node.js google-play-services google-oauth