Reputation: 543
I have a Google App Engine task in task queue performing the following four steps on a file recently uploaded by my app to a Google Drive Account and new files created by resizing the original.
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()
All the steps work, all the files are where they are supposed to be with correct permissions, etc.
However, my log files shows the access_token being refreshed for each step.
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
Is this what I should be expecting? It seems to me that one access_token for four actions running in one loop should suffice.
Thanks, Chris
Upvotes: 0
Views: 415
Reputation: 22286
A typical access_token lasts for one hour. My guess is each request is still using the expired token instead of the shiny new one.
Upvotes: 1