-
Notifications
You must be signed in to change notification settings - Fork 345
Closed
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
After the latest release the problem of retrieving certificate still exists for async mode. Here is the previous fix - #1050
Environment details
- Python version: Python 3.9
- pip version: 22.1.2
google-authversion: 2.10.0
Steps to reproduce
In [1]: from google.oauth2 import _id_token_async
In [2]: from google.auth.transport import _aiohttp_requests
In [3]: certs_url = "https://www.googleapis.com/oauth2/v1/certs"
In [4]: request = _aiohttp_requests.Request()
In [5]: response = await request(certs_url, method="GET")
In [6]: response.status
Out[6]: 200
In [7]: data = await response.data.read()
In [8]: import json
In [9]: json.loads(data.decode("utf-8"))
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
Input In [10], in <cell line: 1>()
----> 1 json.loads(data.decode("utf-8"))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byteI suppose that the problem is in 'Content-Encoding': 'gzip' (response), which is not supported by Request (
| def __init__(self, session=None): |
def __init__(self, session=None):
# TODO: Use auto_decompress property for aiohttp 3.7+
if session is not None and session._auto_decompress:
raise ValueError(
"Client sessions with auto_decompress=True are not supported."
)
self.session = sessioninstead, the following code should be used:
In [12]: response = await request(certs_url, method="GET")
In [13]: data = await response.content()
In [14]: json.loads(data)
Out[14]:
{'fda1066453dc9dc3dd933a41ea57da3ef242b0f7': '-----BEGIN CERTIFICATE-----\nMIIDJzCCAg+gAwIBAgIJAIVR59GV94ZKMA0GCSqGSIb3DQEBBQUAMDYxNDAyBgNV\nBAMMK2ZlZ
...........................
'1549e0aef574d1c7bdd136c202b8d290580b165c': '-----BEGIN CERTIFICATE-----\nMIIDJzCCAg+gAwIBAgIJAOdJ975Uc0N7MA0GCSqGSIb3DQEBBQUAMDYxNDAyBgNV\nBAMMK2ZlZGVyYXRlZC1zaWdub24uc
...........................
e3K0wtBfTrXA/xhJq\nhB+S3TlXx9ZZvvl8UR51TqiQu99X9dzjMateAA9ajeQUMJKgVs7+ojQtyQ==\n-----END CERTIFICATE-----\n'}Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.