メールアドレスを含まず、ユーザー名に「不明なユーザー」という値が含まれている 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