Problem statement with error
I'm able to create a Google Form using the Google Forms API, but I can't get the submitted form responses to notify my PubSub topic.
After creating the form, I'm attempting to create the watch but I get the following error (which is weird because I'm using the same authorized "form service" that was used to create the form in the first place):
code: 400
message: Project does not have necessary OAuth permissions from authorizing user.
status: FAILED_PRECONDITION
Scopes didn't fix it
I've thrown a bunch of scopes at the problem hoping something would stick, but I don't think scopes are the problem (or the fix):
scopes = [
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/forms.body",
"https://www.googleapis.com/auth/forms.body.readonly",
"https://www.googleapis.com/auth/forms.responses.readonly"
]
How I'm authorizing the form service
Here is how I'm authorizing my form service with env var GOOGLE_APPLICATION_CREDENTIALS=/path/to/keyfile.json
and calling the method to create the watch:
authorizer = Google::Auth.get_application_default(scopes)
form_service = Google::Apis::FormsV1::FormsService.new
form_service.authorization = authorizer
form_service.create_watch(form_id, create_watch_request_object)
Pub/Sub Publisher Role
I believe I have set up the topic permissions correctly, and I think this watch creation failure is happening upstream of anything needing this publisher permission, right?
Question
I've combed over the auth section in the Google Forms API docs, but can't see what I could change either in my code or in Google Cloud to get this to work. Could you nudge me in the right direction?