GoogleからJSONにメールアドレスとユーザ名が含まれていないJSONに「Unknown User」という値が含まれています。Google Classroom APIが学生プロフィールを返すメールアドレスを持たない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.readonlyhttps://www.googleapis.com/auth/classroom.profile.emailshttps://www.googleapis.com/auth/classroom.profile.photoshttps://www.googleapis.com/auth/classroom.rosters.readonly
すでにこれを行って、質問を更新しました。私がすでに述べたように、コードは他のすべてのユーザーにとってうまくいきますので、スコープの問題ではありません。 – saurav