google-auth-library-python
                                
                                 google-auth-library-python copied to clipboard
                                
                                    google-auth-library-python copied to clipboard
                            
                            
                            
                        async Application Default Credentials throws coroutine AttributeError in Cloud Run
Environment details
- OS: Linux 55851a4b560d 6.10.0-linuxkit #1 SMP PREEMPT_DYNAMIC Wed Jul 17 10:54:05 UTC 2024 x86_64 Linux
- Python version: 3.12.4
- pip version: 24.0
- google-authversion:- 2.32.0
Steps to reproduce
from google.auth._default_async import default_async
from google.auth.transport import _aiohttp_requests as aiohttp_requests
async def get_credentials():
    creds, project_id = default_async()
    await creds.refresh(aiohttp_requests.Request())   # <- Kaboom
    return creds, project_id
if __name__ == "__main__":
    import asyncio
    asyncio.run(get_credentials())
Here's a stack trace from one of our apps:
[2024-09-16 18:08:11,366] [mjolnir.app] [424] [ERROR] !!! FATAL !!! Unable to determine cloud run service url!
2024-09-16 11:08:11.372 PDT
Traceback (most recent call last):
    File "/usr/local/lib/python3.12/site-packages/mjolnir/app.py", line 2001, in register_gcp_service_url service_url = await get_cloud_run_service_url()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/cloudops/utils.py", line 459, in get_cloud_run_service_url
    await creds.refresh(aiohttp_requests.Request())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/google/auth/compute_engine/credentials.py", line 126, in refresh
    self._retrieve_info(request)
File "/usr/local/lib/python3.12/site-packages/google/auth/compute_engine/credentials.py", line 99, in _retrieve_info
    info = _metadata.get_service_account_info(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/google/auth/compute_engine/_metadata.py", line 318, in get_service_account_info
    return get(request, path, params={"recursive": "true"})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/google/auth/compute_engine/_metadata.py", line 222, in get
content = _helpers.from_bytes(response.data)
                              ^^^^^^^^^^^^^
AttributeError: 'coroutine' object has no attribute 'data'