Getting permission denied while getting subscription details from pub/sub events using service account credentials
Maintainers usually reply within 2 days
@sofisl is already working on this.
Since Feb 29, 2024.
Assessment
This issue has not been assessed yet.
Description
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
- Dominant language
- TypeScript
- Stars
- 12.3k
- Forks
- 2k
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 9
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from googleapis/google-api-nodejs-client
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
googleapis/google-api-nodejs-client#4064 ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 1-2 days Newbie friendliness 5/100
googleapis/google-api-nodejs-client#4067 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 1/100
googleapis/google-api-nodejs-client#4063 ·
Maintainers usually reply within 2 days
-
eMudhra/emSign CA compromise (October 2026): what Cloud SDK Node.js Libraries developers need to doOpen
Difficulty 1/5 Under an hour Newbie friendliness 10/100
googleapis/google-api-nodejs-client#4062 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
googleapis/google-api-nodejs-client#4061 ·
Maintainers usually reply within 2 days
All issues in googleapis/google-api-nodejs-client
Similar issues
-
bug UI
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
wardian-app/Wardian#1746 ·
Maintainers usually reply within 1 day
-
area: interop area: sip-core v3
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
fonoster/routr#705 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openclaw/openclaw#198551 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day