作者:好天气 | 来源:互联网 | 2022-12-06 19:39
我们正在准备一个firebase触发器来处理Android的实时开发人员通知,我们必须使用Google Play Developer API来了解用户订阅的详细信息.因此,我们在Google Play控制台中关联了firebase服务帐户,并授予了必要的访问权限.
我们使用谷歌的nodejs库为googleapis(github链接)编写了一段代码,如下所示:
return google.auth.getClient({
keyFile: path.join(__dirname, './service-account.json'),
scope: 'https://www.googleapis.com/auth/androidpublisher'
}) .then((client) => {
const androidpublisher = google.androidpublisher({
version: 'v3',
auth: client
});
const params = {
packageName: ANDROID_PACKAGE_NAME,
subscriptionId: ANDROID_SUBSCRIPTIONID,
token: token
};
return androidpublisher.purchases.subscriptions.get(params)
.then(res => {
console.log(`The response is ${res.data}`);
return null;
})
.catch(error => {
console.error(error);
});
});
但它返回一个错误状态:'无效的凭据',我对此有点失落.我已经使用curl测试了API和授权令牌,它也显示了401错误响应.
我不确定我的流程是否正确,有人能给我任何建议吗?