Google Forms API创建Watch失败:OAuth权限缺失问题求助
问题描述与错误信息
我可以使用Google Forms API创建Google表单,但无法让表单提交的响应通知我的Pub/Sub主题。
创建表单后,我尝试创建watch,但遇到以下错误(奇怪的是,我使用的是与创建表单时相同的已授权“form service”):
code: 400 message: Project does not have necessary OAuth permissions from authorizing user. status: FAILED_PRECONDITION
添加权限范围未解决问题
我尝试添加了多个权限范围,但认为这不是问题所在(也无法解决):
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" ]
表单服务的授权方式
以下是我使用环境变量GOOGLE_APPLICATION_CREDENTIALS=/path/to/keyfile.json授权表单服务并调用创建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发布者角色
我认为已正确设置主题权限,且此次watch创建失败应该发生在需要该发布者权限的环节之前,对吗?

求助问题
我已经仔细查阅了Google Forms API文档中的授权部分,但仍不清楚需要修改代码或Google Cloud中的哪些设置才能解决问题,恳请指点方向。
内容的提问来源于stack exchange,提问作者aaronkelton
相关产品推荐
相关产品推荐

