googleads / googleads/googleads-python-lib
Incorrect handling of 401 error response
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 749
- Forks
- 967
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
For a single user, using his refresh token to do the following:
# Using googleads v23.0.1
customerService = adwordsClient.GetService('CustomerService', version='v201809')
accounts = customerService.getCustomers()
We get the following:
Traceback (most recent call last):
File "/home/user/project/.venv/lib/python3.6/site-packages/googleads/common.py", line 992, in MakeSoapRequest
*packed_args, _soapheaders=soap_headers)['body']['rval']
File "/home/user/project/.venv/lib/python3.6/site-packages/zeep/proxy.py", line 45, in __call__
kwargs,
File "/home/user/project/.venv/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 130, in send
return self.process_reply(client, operation_obj, response)
File "/home/user/project/.venv/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 195, in process_reply
return self.process_error(doc, operation)
File "/home/user/project/.venv/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 287, in process_error
detail=etree_to_string(doc),
zeep.exceptions.Fault: Unknown fault occured
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/user/project/src/main.py", line 24, in <module>
from jobs.scheduler import scheduleJobs
File "/home/user/project/src/jobs/__init__.py", line 16, in <module>
from api.users import refreshUserEntities
File "/home/user/project/src/api/users.py", line 46, in <module>
from external import adwords_api
File "/home/user/project/src/external/adwords_api/__init__.py", line 1723, in <module>
refreshToken=refreshToken,
File "/home/user/project/.venv/lib/python3.6/site-packages/retrying.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "/home/user/project/.venv/lib/python3.6/site-packages/retrying.py", line 206, in call
return attempt.get(self._wrap_exception)
File "/home/user/project/.venv/lib/python3.6/site-packages/retrying.py", line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "/home/user/project/.venv/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/home/user/project/.venv/lib/python3.6/site-packages/retrying.py", line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "/home/user/project/src/external/adwords_api/__init__.py", line 260, in getDirectlyAccessibleAccountsForRefreshToken
accounts = customerService.getCustomers()
File "/home/user/project/.venv/lib/python3.6/site-packages/googleads/common.py", line 997, in MakeSoapRequest
'{%s}ApiExceptionFault' % self._GetBindingNamespace())
TypeError: a bytes-like object is required, not 'str'
The exception object is of type Fault, and contains the following response:
b'<?xml version=\'1.0\' encoding=\'utf-8\'?>\n<HTML>\n<HEAD>\n<TITLE>Unauthorized</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Unauthorized</H1>\n<H2>Error 401</H2>\n</BODY>\n</HTML>'
I am guessing the API is not returning a proper SOAP response, instead - it is returning an HTML response denoting the error.
I am not sure if the library should handle this, or if the API behavior is invalid.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie in googleads/common.py bei MakeSoapRequest, verfolgen Sie den customerService.getCustomers()-Pfad und untersuchen Sie, wie die Fault-Antwort verarbeitet wird. Bestätigen Sie die erwartete Behandlung der HTML-401-Antwort und überprüfen Sie, dass das abgeschlossene Verhalten nicht mehr den gezeigten TypeError erzeugt und dabei die API-Fehlerinformationen erhalten bleiben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- api
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100