【问题标题】:How to connect pydrive with an Service Account如何将 pydrive 与服务帐户连接
【发布时间】:2020-03-18 09:48:50
【问题描述】:

有没有人有任何示例或文档如何将来自 Google Drive API 的服务帐户与pydrive 连接起来。我设法用 auth2 客户端做到了。

【问题讨论】:

    标签: python-3.x pydrive


    【解决方案1】:

    显然这应该有效,但它没有:

    from pydrive.auth import GoogleAuth
    from pydrive.drive import GoogleDrive
    from oauth2client.service_account import ServiceAccountCredentials
    
    gauth = GoogleAuth()
    scope = ["https://www.googleapis.com/auth/drive"]
    gauth.credentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_FILE, scope)
    drive = GoogleDrive(gauth)
    

    更新:错误是由 google IAM 中的某些权限缺失引起的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-15
      • 1970-01-01
      • 1970-01-01
      • 2013-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-14
      相关资源
      最近更新 更多