Timothy Moody
Timothy Moody

Reputation: 519

Grant Google App Maker Full Google Drive API Scope / Server Rejected Error

I have an app maker application using the Google Drive File picker widget. But uploading files does not work, I get a server rejected error.

enter image description here

API Upload Response

{
"errorMessage": {
    "reason": "REQUEST_REJECTED",
    "additionalInfo": {
        "uploader_service.GoogleRupioAdditionalInfo": {
            "completionInfo": {
                "status": "REJECTED"
            },
            "requestRejectedInfo": {
                "reasonDescription": "agent_rejected"
            }
        }
    },
    "upload_id": "UrqXRaPdnG_DZ0L-iDX5BJsG4XEg"
}

I believe the issue is the app's oauth scopes. It appears to only have read access which is insufficient for uploading new files.

enter image description here

I'd like to grant it full access https://www.googleapis.com/auth/drive but I'm not clear how to do this.

Upvotes: 0

Views: 630

Answers (1)

Morfinismo
Morfinismo

Reputation: 5243

This behavior is a bug and it has been recently introduced as far as I'm aware. To be honest, the full drive scope should be granted when enabling the simple uploads feature in the drive picker but some reason it is not doing it. As a work around, you can put the following in any server script:

/***
Dummy function for drive full permissions
****/
function dummyForDrivePermission(){
  var file = DriveApp.addFile();
}

The above code, will force appmaker to recognize that it needs to upload files, although you will never invoke the function but it will server the purpose of granting the scope you need.

Upvotes: 2

Related Questions