Closed and3rson closed 9 months ago
I found a temporary solution by monkey-patching before_request
in obtained credentials with implementation from _credentials_async.Credentials.before_request
:
from google.auth._credentials_async import Credentials
async def main():
creds, project = default_async()
await creds.refresh(_aiohttp_requests.Request())
creds.before_request = partial(Credentials.before_request, creds)
# ...
Thank you for pointing this out! It seems the pattern in the sync code is that oauth2.credentials.Credentials
inherits from auth.credentials.Credentials
, but for the async code it inherits from the sync equivalent.
I think the correct solution is to add before_request
to the oauth2 async Credentials class. An alternative is to revisit the existing inheritance. We can do that at a later time, when we have the resources to "release" the async code.
Environment details
google-auth
version: 2.23.4Steps to reproduce
Actual result:
This seems to happen since
google.oauth2._credentials_async.Credentials
does not define asynchronous version ofbefore_request
, whilegoogle.auth._credentials_async.Credentials
does this.