What steps will reproduce the problem?
1. Submit a request to a Google API (or any other API that will return a 403
error)
2. API returns a 403: Forbidden error, due to an invalid value being submitted
3. Oauth client libarary catches the 403, thinking that it is an OAuth access
token expired error, and then automatically resubmits the request after
refreshing the token. This results in a loop, as the target API continues to
return the same 403 Error response.
What is the expected output? What do you see instead?
The expected output is indeed a 403 error due to invalid data being submitted,
however the Oauth library should not be handling this exception.
What version of the product are you using? On what operating system?
google-api-python-client-gae-1.0
Please provide any additional information below.
The offending code is in client.py on line 450:
if resp.status in [401, 403]:
# Older API (GData) respond with 403
if resp.status in [401, 403]:
logger.info('Refreshing due to a %s' % str(resp.status))
self._refresh(request_orig)
self.apply(headers)
return request_orig(uri, method, body, clean_headers(headers),
redirections, connection_type)
else:
return (resp, content)
Changing this to:
if resp.status in [401]:
fixes the problem, as 401 errors are the only ones that the Oauth lib. should
be catching + fixing automatically. It may also be worth surfacing this
exception to the outside world, in case the OAuth lib. isn't able to handle it.
Original issue reported on code.google.com by eco...@google.com on 3 Jan 2013 at 7:40
Original issue reported on code.google.com by
eco...@google.com
on 3 Jan 2013 at 7:40