国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

Google Drive API客戶端(Python):對files()。insert()的權限不足

瀏覽:2日期:2022-08-07 13:56:32
如何解決Google Drive API客戶端(Python):對files()。insert()的權限不足?

文件:insert需要具有以下至少一個作用域的授權

https://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/drive.filehttps://www.googleapis.com/auth/drive.appdatahttps://www.googleapis .com / auth /drive.apps.readonly

檢查您要使用哪個范圍進行身份驗證。

解決方法

我正在嘗試使一個簡單的Python Google Drive上傳器正常工作。我已經在開發人員控制臺中創建了一個項目,啟用了DriveAPI,并添加了OAuth 2.0客戶端ID(應用程序類型“其他”)。

我可以在Google云端硬盤的“設置”->“管理應用”中看到該應用程序,并且可以成功執行Google的Python DriveAPI客戶端提供的許多操作。files().insert()但是失敗:

googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart&convert=false&useContentAsIndexableText=false&alt=json returned 'Insufficient Permission'>

這是為了插入到我已使所有人可寫的目錄中,如下所示:

credentials = get_credentials ()http = credentials.authorize (httplib2.Http ())service = discovery.build (’drive’,’v2’,http=http)PARENT_ID='0B1gLgXwTiUzlfmo0UGVsZ1NWdW1nZG9OcENNYkJua2E1d0pqWE14TjFyc2hVMHdEU1h5czQ'perms = service.permissions().list(fileId=PARENT_ID).execute()print ('PERMISSIONS:')for perm in perms['items']: for p in perm:print (p,perm[p])printparent = { 'isRoot': False,'kind': 'drive#parentReference','id': PARENT_ID}service.files ().insert ( body = {'parents' : [parent]},media_body=’./test.txt’,convert=False,useContentAsIndexableText=False).execute ()

其中列出的權限為:

(u’withLink’,True)(u’kind’,u’drive#permission’)(u’etag’,u’'F-w0rsCIWtQP8RGyv_V1DlKfcRk/icwHkDdfUYuMzqZrUsVIyvu85K8'’)(u’role’,u’writer’)(u’type’,u’anyone’)(u’id’,u’anyoneWithLink’)(u’selfLink’,u’https://www.googleapis.com/drive/v2/files/0B1gLgXwTiUzlfmo0UGVsZ1NWdW1nZG9OcENNYkJua2E1d0pqWE14TjFyc2hVMHdEU1h5czQ/permissions/anyoneWithLink’)

任何人都可以指出我所缺少的權限嗎?

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 香港| 客服| 金山区| 汝南县| 安达市| 灵川县| 扎赉特旗| 正镶白旗| 哈尔滨市| 神农架林区| 丰镇市| 亚东县| 陇川县| 定安县| 武清区| 嘉峪关市| 乌拉特中旗| 汾阳市| 昌平区| 云南省| 平乐县| 潞城市| 永寿县| 历史| 乌苏市| 景洪市| 包头市| 南陵县| 富蕴县| 麻栗坡县| 正定县| 维西| 肇源县| 孟村| 襄垣县| 常德市| 新津县| 江门市| 穆棱市| 宾川县| 玉田县|