2
votes

I am intermittently getting this error when calling build on a drive service. I am able to reproduce this with a simple program which has the JSON credentials stored to a file.

#!/usr/bin/python

import httplib2
import sys
from apiclient.discovery import build
from oauth2client.client import Credentials

json_creds = open('creds.txt', 'r').read()
creds = Credentials.new_from_json(json_creds)

http = httplib2.Http()
http = creds.authorize(http)

try:
    drive_service = build('drive', 'v2', http=http)
except Exception:
    sys.exit(-1)

When I run this in a loop, I am seeing a rather high number of errors, this code in a loop fails 15-25% of the time for me.

i=0; while [ $i -lt 100 ]; do python jsoncred.py || echo FAIL ; i=$(( $i + 1 )); done | grep FAIL | wc -l

Now when I take this same code, and just replace 'drive' by 'oauth2', the code runs without problems

I have confirmed that the OAuth token that I am using is valid and have the correct scopes:

"expires_in": 2258,

"scope": "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/userinfo.email",

Looking at my app logs, this seems to have started 2/14/2013 1PM PST. I did not push any new code, so I wonder if this a problem with the API. Is there a bug in the API causing this ?

1
Through an HTTPS proxy I observed: 1. The same exact HTTP request googleapis.com/discovery/v1/apis/drive/v2/rest ( including headers ) sometimes succeeds, and sometimes fails. 2. Output from the failure case is: ` { "error": { "errors": [ { "domain": "global", "reason": "invalidConfiguration", "message": "There was an error generating the Discovery document for this api. Please try again later." } ], "code": 500, "message": "There was an error generating the Discovery document for this api. Please try again later." } } `Kartik Ayyar

1 Answers

2
votes

Google are seeing some reports of increased error rates for the discovery document. Please just retry on 500 error for now, and you should be successful.

One could argue that you should have retry logic for this call anyway, since it is good practice, but the current levels are too high, so, sorry about that.

Update: this should now be fixed.