'Missing necessary OAuth permissions on GCP Pub/Sub
I'm trying to follow this guide here to get push notifications whenever a response has been submitted on a Google Forms form. All prerequisites have been completed, and I can successfully publish a message to my Pub/Sub Topic, which then forwards the message to my webhook, running on NestJS with TypeScript (so Node.js as the environment).
However, I can't wrap my head around an issue I'm having when trying to create a watch, so to link my form to the corresponding topic. According to the guide, it is sufficient to grant the system service account ([email protected]) permission to publish to the topic and then create the watch by using the googleapis
SDK.
Following the code example they provide, I am getting this error message:
{
"code": 400,
"message": "Project does not have necessary OAuth permissions from authorizing user.",
"errors": [{
"message": "Project does not have necessary OAuth permissions from authorizing user.",
"domain": "global",
"reason": "failedPrecondition"
}],
"status": "FAILED_PRECONDITION"
}
I've tried with more scopes, more roles, but nothing seems to help so far. Please advise, I don't know what to try anymore...
Solution 1:[1]
Seems like @DazWilkin was right, creating a watch only works when authorizing the app using an OAuth2 flow. Following the docs I created a consent screen and a client ID and was able to create a watch successfully. Cheers for the hint!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | milksnatcher |