1

メールアドレスを含まず、ユーザー名に「不明なユーザー」という値が含まれている Google から生徒の JSON を取得します。

 {
     "courseId":"1234",
     "profile":{//No email address
             "id":"openId",
             "name":{"fullName":"Unknown user"},//Why "Unknown user"
             "photoUrl":"correct_url"
     },
     "userId":"openId"
}

先生の Google Classroom アカウントにアクセスできないため、テスト アカウントで問題を再現しようとしています。少数のユーザーのみで発生しており、他のすべてのユーザーでは正常に機能しています。

Google Classroom の Java API を使用しています。

使用しているコード例:

Classroom service = getGoogleClassRoomService(accessToken);
if(service != null) {
    ListStudentsResponse studentsResponse = service.courses().students().list(courseId).execute();
    List<Student> students = studentsResponse.getStudents();
    if(students != null) {
        for (Student student : students) {
            if (student.getProfile().getEmailAddress() != null) {
                //Processing student data
            }
        }
    }
}

学生の電子メール アドレスが null になる可能性があるシナリオを知る必要があります。技術的には null であってはなりません。

学生プロファイル JSON 参照の例: https://developers.google.com/classroom/reference/rest/v1/userProfiles#resource-userprofile

ユーザーの認証中に要求されたスコープ:

https://www.googleapis.com/auth/classroom.courses.readonly https://www.googleapis.com/auth/classroom.profile.emails https://www.googleapis.com/auth/classroom.profile.写真 https://www.googleapis.com/auth/classroom.rosters.readonly

4

3 に答える 3

1

ユーザーが削除された可能性がありますか? 状況によっては、ユーザーが削除されている場合、API は名前として「不明なユーザー」を含む (電子メール アドレスを含まない) 「ユーザー」を返します。

于 2016-04-05T14:01:15.987 に答える