使用 classroom api 获取特定课程的老师

get the teacher of specefic course using classrrom api

我正在尝试获取特定教师的课程列表。 我确实喜欢:

String courseId = "64294889578";
ListTeachersResponse response = service1.courses().teachers().list(courseId)
                    .setPageSize(100)
                    .setPageToken(pageToken2)
                    .execute();

我遇到了那个错误:

Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden { "code" : 403, "errors" : [ { "domain" : "global", "message" : "Insufficient Permission", "reason" : "insufficientPermissions" } ], "message" : "Request had insufficient authentication scopes.", "status" : "PERMISSION_DENIED" } at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:150) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.interceptResponse(AbstractGoogleClientRequest.java:321) at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1067) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469) at se.edt.classroom.ClassroomQuickstart.main(ClassroomQuickstart.java:86)

所以我尝试更改

定义的范围
private static final List<String> SCOPES =
Collections.singletonList(ClassroomScopes.CLASSROOM_GUARDIANLINKS_ME_READONLY);

所有现有 范围 例如 CLASSROOM_COURSES,但没有成功。

请问您对解决这个问题有什么想法吗?。 非常感谢

你试过范围CLASSROOM_ROSTERS

HTH

参考: