I am able to access users files by Impersonation.
When I call the classroom get method (https://developers.google.com/classroom/reference/rest/v1/courses/get) the drive Id folder is retrieved, with this fileId I want to call the drive api and get the file permissions BUT....... at this point I don't know who is the user (email) so I can impersonate it.
HINT: the classroom owner is not always the drive folder owner.
Is there a way to access the file without impersonating the user? (because I don't know it).
If I don't impersonate I get 404.
One one is to share the file to the service account but that would be too much there are many files.
Thanks in advance.
try {
let jwtClient = new google.auth.JWT({
email : privatekey.client_email,
key : privatekey.private_key,
scopes : [
'https://www.googleapis.com/auth/drive.file',
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.metadata',
'https://www.googleapis.com/auth/drive.metadata.readonly',
'https://www.googleapis.com/auth/drive.photos.readonly',
'https://www.googleapis.com/auth/drive.readonly'
]
//, subject : 'mail_to_impersonate@gmydomain.edu.pe'
});
//console.log(jwtClient);
jwtClient.authorize(function (err, tokens) {
if (err) {
console.log(err);
return;
} else {
console.log("Successfully connected!");
}
});
let drive = google.drive({ version: 'v3', auth: jwtClient });
let params = {
fileId : 'the_classroom_teacherFolder.id'
};
drive.files.get(params, (err, res) => {
if(err) {
console.log('err:', err);
} else {
console.log('res:', res.data);
}
});
} catch (error) {
console.log(error);
}