经过身份验证的用户尚未授予对文件aaaaaxxxamc的应用程序xxxx89写入权限

时间:2014-08-06 08:17:40

标签: google-app-engine google-drive-api

我正在通过驱动器api从一个帐户更新gdrive中的文件 但是,当我创建另一个帐户并获得相同的权限时 我无法上传文件 请参考相同的屏幕截图

https://3dea925eff6caffb6aa84325890bf3da43e77e1d.googledrive.com/host/0B9vJUCqMBOjtLWwxSlhCSUJRaEE/as.png

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "fileAccess",
    "message": "The authenticated user has not granted the app xxxx189 write access to the file Asasavamc",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 403,
  "message": "The authenticated user has not granted the app xxxxxx189 write access to the file asasasasRvamc"
 }
}

2 个答案:

答案 0 :(得分:0)

更新

我建议您查看一下您的OAuth流程和范围。提供代码有助于查明问题。以下是通过App Engine从Drive中删除文件的工作示例:

import logging
import httplib2
import webapp2

from apiclient.discovery import build
from oauth2client.appengine import OAuth2Decorator
from apiclient import errors

decorator = OAuth2Decorator(
  client_id='YOUR_CLIENT_ID',
  client_secret='YOUR_CLIENT_SECRET',
  scope='https://www.googleapis.com/auth/drive')

class MainHandler(webapp2.RequestHandler):
    @decorator.oauth_required
    def get(self):
        # Get the authorized Http object created by the decorator.
        http = decorator.http()

        # Construct the drive client
        drive_service = build('drive', 'v2', http=http)

        # Delete file
        try:
            drive_service.files().delete(fileId="FILE_ID").execute()
        except errors.HttpError, error:
            logging.error('An error occurred: %s' % error)


app = webapp2.WSGIApplication([('/', MainHandler),
                               (decorator.callback_path, decorator.callback_handler())],
                              debug=True)

答案 1 :(得分:0)

请更新readonly to DriveScopes.DRIVE_FILE, DriveScopes.DRIVE, and DriveScopes.DRIVE_APPDATA

的范围值