|
通过托管OAuth认证访问Google Classroom API。管理课程、课程作业、学生、教师、公告和提交内容。
bash
https://gateway.maton.ai/google-classroom/{api-path}
Google Classroom API使用以下路径模式:
https://gateway.maton.ai/google-classroom/v1/{resource}
所有请求都需要在Authorization头部中包含Maton API密钥:
Authorization: Bearer $MATONAPIKEY
环境变量: 将您的API密钥设置为MATONAPIKEY:
bash
export MATONAPIKEY=YOURAPIKEY
在https://ctrl.maton.ai管理您的Google Classroom OAuth连接。
bash
python3 <
req = urllib.request.Request(https://ctrl.maton.ai/connections?app=google-classroom&status=ACTIVE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python3 <
data = json.dumps({app: google-classroom}).encode()
req = urllib.request.Request(https://ctrl.maton.ai/connections, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python3 <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id})
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
json
{
connection: {
connection_id: 8efa1361-0e86-40b1-a63b-53a5051f8ac6,
status: ACTIVE,
creation_time: 2026-02-14T00:00:00.000000Z,
lastupdatedtime: 2026-02-14T00:00:00.000000Z,
url: https://connect.maton.ai/?session_token=...,
app: google-classroom,
metadata: {}
}
}
在浏览器中打开返回的url以完成OAuth授权。
bash
python3 <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id}, method=DELETE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果您有多个Google Classroom连接,请使用Maton-Connection头部指定要使用的连接:
bash
python3 <
req = urllib.request.Request(https://gateway.maton.ai/google-classroom/v1/courses)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Maton-Connection, 8efa1361-0e86-40b1-a63b-53a5051f8ac6)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果省略,网关将使用默认(最旧的)活动连接。
bash
GET /v1/courses
GET /v1/courses?courseStates=ACTIVE
GET /v1/courses?teacherId=me
GET /v1/courses?studentId=me
GET /v1/courses?pageSize=10
查询参数:
响应:
json
{
courses: [
{
id: 825635865485,
name: 编程入门,
section: A班,
descriptionHeading: CS 101,
description: 学习编程基础知识,
ownerId: 102753038276005039640,
creationTime: 2026-02-14T01:53:58.991Z,
updateTime: 2026-02-14T01:53:58.991Z,
enrollmentCode: 3qsua37m,
courseState: ACTIVE,
alternateLink: https://classroom.google.com/c/ODI1NjM1ODY1NDg1,
guardiansEnabled: false
}
],
nextPageToken: ...
}
bash
GET /v1/courses/{courseId}
bash
POST /v1/courses
Content-Type: application/json
{
name: 课程名称,
section: A班,
descriptionHeading: 课程标题,
description: 课程描述,
ownerId: me
}
响应:
json
{
id: 825637533405,
name: 课程名称,
section: A班,
ownerId: 102753038276005039640,
courseState: PROVISIONED,
enrollmentCode: abc123
}
bash
PATCH /v1/courses/{courseId}?updateMask=name,description
Content-Type: application/json
{
name: 更新后的课程名称,
description: 更新后的描述
}
注意: 使用updateMask查询参数指定要更新的字段。
bash
DELETE /v1/courses/{courseId}
注意: 删除前必须先归档课程。要归档,请使用courseState: ARCHIVED更新课程。
bash
GET /v1/courses/{courseId}/courseWork
GET /v1/courses/{courseId}/courseWork?courseWorkStates=PUBLISHED
GET /v1/courses/{courseId}/courseWork?orderBy=dueDate
查询参数:
bash
GET /v1/courses/{courseId}/courseWork/{courseWorkId}
bash
POST /v1/courses/{courseId}/courseWork
Content-Type: application/json
{
title: 作业标题,
description: 作业描述,
workType: ASSIGNMENT,
state: PUBLISHED,
maxPoints: 100,
dueDate: {
year: 2026,
month: 3,
day: 15
},
dueTime: {
hours: 23,
minutes: 59
}
}
作业类型:
状态:
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 google-classroom-1776420049 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 google-classroom-1776420049 技能
skillhub install google-classroom-1776420049
文件大小: 5.75 KB | 发布时间: 2026-4-17 19:22