You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Getting an error coroutine 'AsyncRestClient._request_with_session' was never awaited #555
I've been noticing some errors in our logs ever since we bumped the Auth0-python lib version to 4.6.0:
2023-11-21 23:42:35 File "/osiris/pkgs/osiris_api_service/providers/auth0/identity_provider_client.py", line 82, in _get_auth0_access_token
2023-11-21 23:42:35 return response["access_token"]
2023-11-21 23:42:35 ~~~~~~~~^^^^^^^^^^^^^^^^
2023-11-21 23:42:35 INFO: 169.254.1.1:28012 - "GET /organizations/5e220319-013b-****-****-2dfeb8ad7cf0/invitations HTTP/1.1" 200 OK
2023-11-21 23:42:36 TypeError: 'coroutine' object is not subscriptable
2023-11-21 23:44:42 sys:1: RuntimeWarning: coroutine 'AsyncRestClient._request_with_session' was never awaited
2023-11-21 23:44:42 RuntimeWarning: Enable tracemalloc to get the object allocation traceback
I don't have it captured in a test to reproduce it, but I'll share our authentication code.
Reproduction
AsyncGetToken=asyncify(authentication.GetToken)
...
@propertyasyncdefclient(self) ->AsyncAuth0:
""" This property method returns an instance of AsyncAuth0. If the instance does not exist, it creates a new one using the domain and access token obtained from the _get_auth0_access_token method. """ifself._clientisNone:
auth0_token=awaitself._get_auth0_access_token()
self._client=AsyncAuth0(self.domain, auth0_token)
returnself._clientasyncdef_get_auth0_access_token(self) ->str:
""" Performs the Auth0 authentication and returns the access token. """get_token=AsyncGetToken(self.domain, self.client_id, self.client_secret)
response=awaitget_token.client_credentials_async(f"https://{self.domain}/api/v2/")
returnresponse["access_token"] # <--- fails here with TypeError: 'coroutine' object is not subscriptable
This also seems to break the _async methods which suddenly return a coroutine instead of the object. For example
response=awaitself.auth0.users.create_async({'given_name': given_name,
[...]
})
returnresponse['user_id'] # indexing breaks here in 4.6 because response is a coroutine
returns a coroutine even after the await. This code works unchanged with 4.4 (and returns a dict) but breaks with 4.6 (and returns a coroutine).
Activity
chipxsd commentedon Nov 22, 2023
Not sure, but I think the error is referring to this:
auth0-python/auth0/rest_async.py
Lines 87 to 93 in 21add34
adamjmcgrath commentedon Nov 22, 2023
Thanks for raising this @chipxsd
Have identified the issue and a fix is in flight #556
Please continue to use 4.5.0 until this is resolved
WarpedPixel commentedon Nov 23, 2023
This also seems to break the
_asyncmethods which suddenly return a coroutine instead of the object. For examplereturns a coroutine even after the await. This code works unchanged with 4.4 (and returns a dict) but breaks with 4.6 (and returns a coroutine).
Fix rest_async and async tests (#556)