Google drive api 我应该多久看一次;由于401";及;刷新访问“U令牌”;

Google drive api 我应该多久看一次;由于401";及;刷新访问“U令牌”;,google-drive-api,Google Drive Api,我在任务队列中有一个Google App Engine任务,对我的应用程序最近上传到Google Drive帐户的文件和通过调整原始文件大小创建的新文件执行以下四个步骤 1- file = service.files().get(fileId=googleDriveFileId).execute() 2- resizedImage = resizeImage(theImage,currentWidth,currentHeight,135,90); newImage = putGoogle

我在任务队列中有一个Google App Engine任务,对我的应用程序最近上传到Google Drive帐户的文件和通过调整原始文件大小创建的新文件执行以下四个步骤

1- file = service.files().get(fileId=googleDriveFileId).execute()

2- resizedImage = resizeImage(theImage,currentWidth,currentHeight,135,90);
   newImage = putGoogleDriveFile(user,resizedImage,imageName,'image/jpeg',None,"image")

3- service.permissions().insert(fileId=file_id, body=new_permission).execute()

4- service.files().delete(fileId=googleDriveFileId).execute()
所有的步骤都有效,所有的文件都在正确的权限范围内,等等

但是,我的日志文件显示每个步骤刷新的访问令牌

 URL being requested: https://www.googleapis.com/discovery/v1/apis/drive/v2/rest?userIp=0.1.0.2
2012-09-01 07:51:10.578 URL being requested: https://www.googleapis.com/drive/v2/files/0Bx4nwQIkoY_7OVE4U3JtcUVPMzQ?alt=json
2012-09-01 07:51:10.602 Refreshing due to a 401
2012-09-01 07:51:10.602 Refresing access_token
2012-09-01 07:51:11.222 putting drive file
2012-09-01 07:51:11.231 have credentials
2012-09-01 07:51:11.232 URL being requested:  https://www.googleapis.com/discovery/v1/apis/drive/v2/rest?userIp=0.1.0.2
2012-09-01 07:51:11.478 URL being requested: https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart&alt=json
2012-09-01 07:51:11.505 Refreshing due to a 401
2012-09-01 07:51:11.505 Refresing access_token
2012-09-01 07:51:13.676 setting permissions
2012-09-01 07:51:13.682 have credentials
2012-09-01 07:51:13.684 URL being requested: https://www.googleapis.com/discovery/v1/apis/drive/v2/rest?userIp=0.1.0.2
2012-09-01 07:51:13.777 URL being requested: https://www.googleapis.com/drive/v2/files/0Bx4nwQIkoY_7dXhUbWdLaU9feUU/permissions?alt=json
2012-09-01 07:51:13.803 Refreshing due to a 401
2012-09-01 07:51:13.803 Refresing access_token
2012-09-01 07:51:14.484 have credentials
2012-09-01 07:51:14.485 URL being requested: https://www.googleapis.com/discovery/v1/apis/drive/v2/rest?userIp=0.1.0.2
2012-09-01 07:51:14.656 URL being requested: https://www.googleapis.com/drive/v2/files/0Bx4nwQIkoY_7UUJadzNGa2oxRjA
2012-09-01 07:51:15.098 Refreshing due to a 401
2012-09-01 07:51:15.098 Refresing access_token
这是我应该期待的吗?在我看来,对于在一个循环中运行的四个操作,一个access_令牌就足够了

谢谢,
克里斯

一个典型的访问令牌持续一小时。我猜每个请求仍然使用过期的令牌,而不是闪亮的新令牌。

我也遇到了这个问题。python api似乎正在刷新令牌,但没有在请求中使用新的访问令牌。因此,在我的例子中,它在第一个小时运行良好,但一旦原始令牌过期,它就会失败。我在日志中看到相同的“刷新访问令牌”消息,但由于“403:用户对此配置文件没有足够的权限”,调用失败