通过托管OAuth集成Google Forms API,可创建表单、添加问题并获取响应。适用于需要与Google交互的场景。
Google Formation是一项面向实际任务的技能,主要用于使用管理好的 OAuth 认证访问 Google Formation API...;Create formes, 添加问题, 并检索回复.;
它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。使用时应结合输入条件选择合适的执行方式,核对必要参数、依赖环境与输出内容,并按原始要求处理异常情况。从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;
若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。该技能适合用于一次性任务,也可以接入自动化工作流,与其他技能或上层代理配合完成更完整的业务链路;在组合使用时,应明确每一步的输入输出关系,并避免不同步骤之间出现参数冲突。
通过受管 OAuth 认证访问 Google Forms API。创建表单、添加问题,并获取响应数据。
# 获取表单
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/google-forms/v1/forms/{formId}')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
https://api.maton.ai/google-forms/{native-api-path}
Maton 将请求代理至 forms.googleapis.com,并自动注入您的 OAuth Token。
所有请求均需在 Authorization 请求头中提供 Maton API 密钥:
Authorization: Bearer $MATON_API_KEY
环境变量:请将您的 API 密钥设置为 MATON_API_KEY:
export MATON_API_KEY="YOUR_API_KEY"
在 https://api.maton.ai 管理您的 Google OAuth 连接。
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections?app=google-forms&status=ACTIVE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'google-forms'}).encode()
req = urllib.request.Request('https://api.maton.ai/connections', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections/{connection_id}')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应示例:
{
"connection": {
"connection_id": "{connection_id}",
"status": "ACTIVE",
"creation_time": "2025-12-08T07:20:53.488460Z",
"last_updated_time": "2026-01-31T20:03:32.593153Z",
"url": "https://connect.maton.ai/?session_token=...",
"app": "google-forms",
"metadata": {}
}
}
在浏览器中打开返回的 url 以完成 OAuth 授权流程。
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections/{connection_id}', method='DELETE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
若您拥有多个 Google Forms 连接,请使用 Maton-Connection 请求头指定目标连接:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/google-forms/v1/forms/{formId}')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Maton-Connection', '{connection_id}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
当存在多个连接时,请始终包含该请求头,以确保请求路由至预期的 Google 账户。
GET /google-forms/v1/forms/{formId}
POST /google-forms/v1/forms
Content-Type: application/json
{
"info": {
"title": "Customer Feedback Survey"
}
}
POST /google-forms/v1/forms/{formId}:batchUpdate
Content-Type: application/json
{
"requests": [
{
"createItem": {
"item": {
"title": "What is your name?",
"questionItem": {
"question": {
"required": true,
"textQuestion": {"paragraph": false}
}
}
},
"location": {"index": 0}
}
}
]
}
GET /google-forms/v1/forms/{formId}/responses
GET /google-forms/v1/forms/{formId}/responses/{responseId}
{
"createItem": {
"item": {
"title": "Question text",
"questionItem": {
"question": {
"required": true,
"textQuestion": {"paragraph": false}
}
}
},
"location": {"index": 0}
}
}
{
"createItem": {
"item": {
"title": "Select an option",
"questionItem": {
"question": {
"choiceQuestion": {
"type": "RADIO",
"options": [
{"value": "Option A"},
{"value": "Option B"}
]
}
}
}
},
"location": {"index": 0}
}
}
{
"createItem": {
"item": {
"title": "Rate your experience",
"questionItem": {
"question": {
"scaleQuestion": {
"low": 1,
"high": 5,
"lowLabel": "Poor",
"highLabel": "Excellent"
}
}
}
},
"location": {"index": 0}
}
}
textQuestion — 短文本或段落文本choiceQuestion — 单选(RADIO)、多选(CHECKBOX)或下拉(DROPDOWN)scaleQuestion — 线性量表dateQuestion — 日期选择器timeQuestion — 时间选择器const response = await fetch(
'https://api.maton.ai/google-forms/v1/forms/FORM_ID/responses',
{
headers: {
'Authorization': `Bearer ${process.env.MATON_API_KEY}`
}
}
);
import os
import requests
response = requests.get(
f'https://api.maton.ai/google-forms/v1/forms/FORM_ID/responses',
headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'}
)
updateMask 指定需更新的字段curl -g 参数禁用 glob 解析jq 或其他命令时,在部分 shell 环境中环境变量(如 $MATON_API_KEY)可能无法正确展开,导致“Invalid API key”错误| 状态码 | 含义 |
|---|---|
| 400 | 缺少 Google Forms 连接 |
| 401 | Maton API 密钥无效或缺失 |
| 429 | 请求频率受限(每账户 10 次/秒) |
| 4xx/5xx | 来自 Google Forms API 的透传错误 |
MATON_API_KEY 环境变量是否已设置:echo $MATON_API_KEY
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
google-forms 开头。例如:https://api.maton.ai/google-forms/v1/forms/{formId}https://api.maton.ai/forms/v1/forms/{formId}