Tuesday, 9 February 2021

Google Drive API: How to create a file in appDataFolder?

I'm reading this documenation: https://developers.google.com/drive/api/v3/appdata

This is my code:

var fileMetadata = {
    'name': 'config.json',
    'parents': ['appDataFolder']
};
var media = {
    mimeType: 'application/json',
    body: '"sample text"'
};
const request = gapi.client.drive.files.create({
    resource: fileMetadata,
    media,
    fields: 'id'
})
request.execute(function (err, file) {
    if (err) {
        // Handle error
        console.error(err);
    } else {
        console.log('Folder Id:', file.id);
    }
})

I get a 403 error: "The user does not have sufficient permissions for this file."

Does not the user have permission to create a file in his appDataFolder? How to create a file in it?

The scope of gapi client is 'https://ift.tt/18JQG6D' and the user accepted it.



from Google Drive API: How to create a file in appDataFolder?

No comments:

Post a Comment