【发布时间】:2020-11-28 15:46:58
【问题描述】:
Google 课堂 API 有问题
使用 Google Classroom API v1,通过 oAuth2 授权,请求
teachers.create({
courseId,
requestBody: {
userId: email
}
})
并得到以下错误:
config: {
> url: 'https://classroom.googleapis.com/v1/courses/237584048292/teachers',
> method: 'POST',
> data: {
> courseId: '237584048292',
> profile: {},
> userId: 'dgrz5.0@gmail.com'
> },
> body: '{"courseId":"237584048292","profile":{},"userId":"dgrz5.0@gmail.com"}',
> },
> data: {
> error: {
> code: 403,
> message: 'The caller does not have permission',
> errors: [Array],
> status: 'PERMISSION_DENIED'
> }
> },
>
> status: 403,
> statusText: 'Forbidden',
> request: {
> responseURL: 'https://classroom.googleapis.com/v1/courses/237584048292/teachers'
> }
> }
【问题讨论】:
-
你从哪里请求它?你在使用特定的库吗?您是否设置了正确的范围?呼叫帐户是管理员吗?我建议也许使用API Explorer 来测试您的请求并确保它严格来说是权限错误。如果您使用的是库,我建议您通过 quickstart guides 之一来确保您拥有经过正确身份验证的应用程序(如果您的请求在资源管理器中有效)。
标签: google-api google-classroom