First some background, Using Service Accounts with GData Spreadsheet API for an app installed via Google Apps Marketplace.
credentials = SignedJwtAssertionCredentials(
SERVICE_ACCOUNT_EMAIL,
PRIVATE_KEY,
scope = SCOPE,
sub = "admin@domain.com")
auth2token = gauth.OAuth2TokenFromCredentials(credentials)
client = SpreadsheetsClient()
auth2token.authorize(client)
q = SpreadsheetQuery(title= "ItemMaster",title_exact=True,)
feed = client.get_spreadsheets(query = q)
The problem is that the API calls fail randomly with,
AccessTokenRefreshError: Invalid response 403.
Failed to retrieve access token: You are not authorized to perform this request.
I tried doing a test in which 10 API calls are made one after another with 1 second intervals between them, atleast 4 API calls failed with the above error.
I tried checked the quota on API console and that is not being exceeded, Per user limits on the API are at 100 requests/user/second for the Drive API, and billing is enabled.
PS: This question is different from Getting AccessTokenRefreshError: invalid_grant in Google API fro service account and Google API Python Client - AccessTokenRefreshError which are related to invalid_grant
while my issue is specifically related to Random Failures of API calls
EDIT: The problem seems to be related to #210 in google-api-python-client