0

We are using Google Drive API in our Google App Engine application. This weekend we noticed that it has problems with updating spreadsheet title. We are getting the following error:

HttpError: <HttpError 403 when requesting https://www.googleapis.com/drive/v2/files/1_X51WMK0U12rfPKc2x60E_EuyqtQ8koW-NSRZq7Eqdw?quotaUser=5660071165952000&fields=title&alt=json returned "The authenticated user has not granted the app 593604285024 write access to the file 1_X51WMK0U12rfPKc2x60E_EuyqtQ8koW-NSRZq7Eqdw">

Other calls to Google Drive API succeed. We just have the problem with this one. Also this functionality worked properly for a long time. Is it possible that some update on Google side has broken this?

The minimal code to reproduce the issue is:

class TestDriveUpdate(webapp2.RequestHandler):
    def get(self):
        credentials = StorageByKeyName(Credentials,
                                       '103005000283606027776',
                                       'credentials').get()
        spreadsheet_key = '1_X51WMK0U12rfPKc2x60E_EuyqtQ8koW-NSRZq7Eqdw'
        quota_user = '5660071165952000'
        body = {"title": 'Test'}
        fields = "title"

        http = httplib2.Http(timeout=60)
        credentials.authorize(http)
        gdrive = apiclient.discovery.build('drive', 'v2', http=http)
        response = gdrive.files().update(
                fileId=spreadsheet_key,
                body=body,
                fields=fields,
                quotaUser=quota_user
            ).execute()

        self.response.write("OK")
Slawek Rewaj
  • 809
  • 8
  • 16
  • "The authenticated user has not granted the app 593604285024 write access to the file 1_X51WMK0U12rfPKc2x60E_EuyqtQ8koW-NSRZq7Eqdw". That should tell you. What permissions did you set up for the file when created? Is app 593604285024 supposed to be auth'd? – GAEfan Aug 22 '16 at 15:50
  • The problem is that this is just not true ;) This file was created by exactly the same application. How is it possible that it doesn't have write access to the file? – Slawek Rewaj Aug 23 '16 at 09:52

1 Answers1

1

Based from this documentation, error occurs when the requesting app is not on the ACL for the file and the user never explicitly opened the file with this Drive app. Found this SO question which states that the scope strings must match exactly between your code and the Admin Console, including trailing slashes, etc. Make sure also that Drive Apps are allowed on the domain ("Allow users to install Google Drive apps").

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59