从服务帐户获取Google API中的AccessTokenRefreshError:invalid_grant

use*_*r26 6 google-tasks-api

我正在关注这个例子

https://code.google.com/p/google-api-python-client/source/browse/samples/service_account/tasks.py

  credentials = SignedJwtAssertionCredentials(
      '141491975384@developer.gserviceaccount.com',
      key,
      scope='https://www.googleapis.com/auth/tasks')
  http = httplib2.Http()
  http = credentials.authorize(http)

  service = build("tasks", "v1", http=http)

  # List all the tasklists for the account.
  lists = service.tasklists().list().execute(http=http)
  pprint.pprint(lists)
Run Code Online (Sandbox Code Playgroud)

问题是,它有时工作,我把列表作为JSON,并在运行程序几次后,我得到错误

  File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 710, in _do_refresh_request
    raise AccessTokenRefreshError(error_msg)
oauth2client.client.AccessTokenRefreshError: invalid_grant
Run Code Online (Sandbox Code Playgroud)

Dam*_*mon 0

我正在界面 Google Drive 但发现了同样的错误。第 160 期中有一份关于在本地计算机上设置适当时间的报告。自从升级到 Mac Mavericks 后,我发现我需要不断更新系统时间。我收到了您报告的错误,将系统时间设置回当前时间并消除了错误。