我在任务队列中有一个 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()
所有步骤都有效,所有文件都在它们应该具有正确权限的位置,等等。
但是,我的日志文件显示每一步都刷新了 access_token。
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_token 就足够了。
谢谢,克里斯