smokybob
smokybob

Reputation: 662

drive.readonly.metadata not enough for revisions.list

I've been using the Google APIs Client Library for JS heavily to access the revision history of some files and see if they are published on the web, for the last 2 weeks and using the drive.readonly.metadata scope.

The following code worked until this morning

function checkRevision(childItem, language) {
    var requestRevision = gapi.client.drive.revisions.list({
        'fileId': childItem.id,
        'fields': 'items/publishedOutsideDomain'
    });

    var fileId = childItem.id;
    requestRevision.execute(function(revisions) {

        //Check if the latest revision is published
        if (revisions && !revisions.error) {
            if (revisions.items[revisions.items.length - 1].publishedOutsideDomain) {
                addBlogPostToMenu(fileId, language);//the file is ok do the real job
            }
        }
    });
}

Not the response I get from requestRevision.execute is

403 Forbidden

    {
     "error": {
      "errors": [
       {
        "domain": "global",
        "reason": "forbidden",
        "message": "Forbidden"
       }
      ],
      "code": 403,
      "message": "Forbidden"
     }
    }

The webapp was authorized correctly with

    gapi.auth.authorize({
        'client_id': CLIENT_ID,
        'scope': 'https://www.googleapis.com/auth/drive.readonly.metadata',
        'immediate': true
    },
    handleAuthResult); 

Changing the scope to drive.readonly fixed it but I think revisions are metadata and not the actual file so drive.readonly.metadata should be the most appropriate scope.

P.S. even tried with the APIs Explorer and I get the same error.

Sample File Id :

1ppLjLg2_ItTGHn_tVSEyOm2bwOtfqiGEb4MZQyAnE7c

Upvotes: 0

Views: 128

Answers (1)

Burcu Dogan
Burcu Dogan

Reputation: 9213

This is the expected behavior, similarly files.list don't respond back with exportLinks or a downloadUrl if you're only authorized for drive.readonly.metadata.

Upvotes: 2

Related Questions