问题
I want to get drive file of user (metadata, content, downloadUrl) not created by my application with access token have only drive.file scope. Can anyone have a solution for this one? Thank you.
gapi.client.load('drive', 'v3', () => {
gapi.auth.setToken({
access_token: user.services.google.accessToken,
expires_in: user.services.google.expiresAt,
});
gapi.client.drive.files.get({
fileId: file.id,
fields: 'webContentLink',
}).then( test => {
console.log('test', test);
})
});
回答1:
You need to have access to user's file in order to obtain the webContentLink
You can incorporate in your script a function that allows the user to share his file with you, something like:
drive.permissions.create({
resource: {
'type': 'user',
'role': 'reader',
'emailAddress': 'YOUR EMAIL'
},
fileId: file.id,
}
...);
来源:https://stackoverflow.com/questions/59283307/is-there-anyway-to-get-private-file-of-user-with-drive-file-scope