Python 在Google OAuth 2.0(服务帐户)中,哪个电子邮件用于驱动器?

Python 在Google OAuth 2.0(服务帐户)中,哪个电子邮件用于驱动器?,python,oauth-2.0,google-openid,google-authentication,google-api-python-client,Python,Oauth 2.0,Google Openid,Google Authentication,Google Api Python Client,我正试图通过谷歌认证来使用谷歌硬盘,但当我尝试列出文件时,没有一个文件返回(我知道我的谷歌硬盘中有文件) 我正在使用这段代码,当我执行它时,没有列出任何文件。它是否尝试获取与我的帐户关联的文件blah@blah.com或298741233858@developer.gserviceaccount.com? 因为我有文件在里面blah@blah.com但是298741233858@developer.gserviceaccount.com只是为开发人员访问而创建的 from oauth2clie

我正试图通过谷歌认证来使用谷歌硬盘,但当我尝试列出文件时,没有一个文件返回(我知道我的谷歌硬盘中有文件)

我正在使用这段代码,当我执行它时,没有列出任何文件。它是否尝试获取与我的帐户关联的文件blah@blah.com或298741233858@developer.gserviceaccount.com? 因为我有文件在里面blah@blah.com但是298741233858@developer.gserviceaccount.com只是为开发人员访问而创建的

from oauth2client.client import SignedJwtAssertionCredentials
import httplib2
from apiclient.discovery import build

email = 'blah@blah.com'
service_email = '298741233858@developer.gserviceaccount.com'
scope = 'https://www.googleapis.com/auth/drive'

f = file('google-api-key', 'rb')
key = f.read()
f.close()

credentials = SignedJwtAssertionCredentials(service_email, key, scope=scope)
http = httplib2.Http()
http = credentials.authorize(http)
drive_service = build('drive', 'v2', http=http)

def get_all_files(service):
  result = []
  page_token = None
  while True:
    param = {}
    if page_token:
      param['pageToken'] = page_token
    files = service.files().list(**param).execute()
    result.extend(files['items'])
    page_token = files.get('nextPageToken')
    if not page_token:
      break
  return result

files = get_all_files(drive_service)
print files

您是否将服务帐户电子邮件设置为您的邮箱中的备用电子邮件地址?嗨,Jan!不,我使用我的普通电子邮件设置服务帐户。我可以在该页面上看到它与我的普通电子邮件相关联。所以基本上,如果我理解正确。。。如果我使用blah@blah.com,然后将一些文件添加到驱动器,然后我使用blah@blah.com并收到电子邮件298741233858@developer.gserviceaccount.com-我用298741233858@developer.gserviceaccount.com对于所有API访问,它应该允许我访问与blah@blah.com? (即我上传的文件)我不确定。我想我在某个地方读到过,你必须设置服务帐户电子邮件作为你想要访问的帐户的替代电子邮件,但也可能是我的记忆不好,因为我再也找不到了;)关于这个问题的解决方案还有什么进一步的信息吗?对于一个正常的帐户,有相同的问题。它使用具有服务帐户的域进行工作。但是不能让它为普通用户工作。