Getting permission denied while getting subscription details from pub/sub events using service account credentials
维护者通常 1 天内回复
@sofisl 已经在做这个了。
开始于 2024年2月29日。
评估
这个 Issue 还没有评估数据。
描述
Hi there,
I used google cloud pub/sub api to receive messages using the endpoint url, here I was able to receive events in the backend, but when I tried getting subscription details using the service account credentails, I got permission denied. It worked successfully when tried using OAuth redirecting to the browser, but I need to handle it in the backend to store/modify subscription details in the database, so OAuth2 doesn't seem to be viable option.
I have tried the following code snippet.
require('dotenv').config();
(async () => {
const subscription = {
message: {
data: '<sample-subscription>',
messageId: '10553462436995277',
message_id: '10553462436995277',
publishTime: '2024-02-27T12:30:55.34Z',
publish_time: '2024-02-27T12:30:55.34Z'
},
subscription: '<subscription-id>',
};
const decodedData = Buffer.from(subscription.message.data, 'base64').toString('utf-8');
console.log(decodedData);
const {
subscriptionNotification: { purchaseToken, subscriptionId },
packageName,
} = JSON.parse(decodedData);
console.log(JSON.parse(decodedData));
const { google } = require('googleapis');
const androidpublisher = google.androidpublisher({
version: 'v3',
auth: new google.auth.JWT({
keyFile: './creds.json', // service account creds, i saw in the google console that it has owner permissions
scopes: ['https://www.googleapis.com/auth/androidpublisher'],
}),
});
const response = await androidpublisher.purchases.subscriptions.get({
packageName: packageName,
subscriptionId: subscriptionId,
token: purchaseToken,
});
console.log(response);
})();
The error I am getting is:
{
status: 401,
code: 401,
errors: [
{
message: 'The current user has insufficient permissions to perform the requested operation.',
domain: 'androidpublisher',
reason: 'permissionDenied'
}
],
}
these are permissions I saw in the google cloud console.
Don't know what to do in this case!
Thanks in advance!
@proppy @dazuma @jskeet @hansoksendahl @andrelaszlo
- 主要语言
- TypeScript
- 星标
- 12.3k
- 派生
- 2k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 21
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
googleapis/google-api-nodejs-client 的其他 Issue
-
难度 5/5 一周以上 新手友好度 32/100
googleapis/google-api-nodejs-client#3932 · 1 条评论 ·
维护者通常 1 天内回复
-
[Discovery Engine] streamAnswer is typed as one AnswerQueryResponse, but REST returns frame arrays未关闭
难度 3/5 1-2 天 新手友好度 64/100
googleapis/google-api-nodejs-client#3930 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 76/100
googleapis/google-api-nodejs-client#3927 · 1 个 reaction ·
维护者通常 1 天内回复
-
size: l type: feature request
难度 4/5 3-5 天 新手友好度 35/100
googleapis/google-api-nodejs-client#3926 ·
维护者通常 1 天内回复
-
type: feature request
难度 5/5 一周以上 新手友好度 15/100
googleapis/google-api-nodejs-client#3903 ·
维护者通常 1 天内回复
查看 googleapis/google-api-nodejs-client 的全部 Issue
相似的 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 88/100
inu-appcenter/memorIN-frontend#106 ·
维护者通常 1 天内回复
-
kind/bug
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 7 天内回复
-
[Bug] @deck.gl/arcgis dist import resolves to unpublished @deck.gl/core source path (9.3.11, 9.4.0)未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
CSCfi/sd-search-ui#145 ·
维护者通常 1 天内回复
-
check:passed streams:add
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复