Repository: auth0/auth0-python

Issue:
GetToken and asyncify: Algorithm not supported
### Checklist

- [X] I have looked into the [Readme](https://github.com/auth0/auth0-python#readme) and [Examples](https://github.com/auth0/auth0-python/blob/master/EXAMPLES.md), and have not found a suitable solution or answer.
- [X] I have looked into the [API documentation](https://auth0-python.readthedocs.io/en/latest/) and have not found a suitable solution or answer.
- [X] I have searched the [issues](https://github.com/auth0/auth0-python/issues) and have not found a suitable solution or answer.
- [X] I have searched the [Auth0 Community](https://community.auth0.com) forums and have not found a suitable solution or answer.
- [X] I agree to the terms within the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).

### Description

When wrapping `GetToken` with `asyncify`, it passes the wrong arguments via the wrapper, and it fails with an exception 'Algorithm not supported'.

I believe the error resides [here](https://github.com/auth0/auth0-python/blob/master/auth0/asyncify.py#L59-L61). When I debug this piece of code, I see that it initializes the `AuthenticationBase` with `client_assertion_signing_alg = "https"`. That makes me believe that the order of the arguments passed onto `asyncify(GetToken)` -> `GetToken` ->`AuthenticationBase` is incorrect when using `asyncify`.


### Reproduction

This is what I basically do (I'm migrating from 3.x to 4.x):

```python
AsyncGetToken = asyncify(GetToken)

get_token = AsyncGetToken(domain, client_id)

# This fails with 'Algorithm not supported'.
response = await self.get_token.login_async(
    username=username,
    password=password,
    realm="Username-Password-Authentication",
    scope="openid profile email",
)
```

### Additional context

Stack trace:

```
Traceback (most recent call last):
  File "lib/python3.10/site-packages/jwt/api_jws.py", line 95, in get_algorithm_by_name
    return self._algorithms[alg_name]
KeyError: 'https'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "cli.py", line 178, in run
    sys.exit(asyncio.run(main(sys.argv)))
  File "/usr/local/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "cli.py", line 167, in main
    await command_devices(arguments)
  File "cli.py", line 55, in command_devices
    await account.update_devices()
  File "client.py", line 61, in update_devices
    device.id: device for device in await self.traccar_api.get_devices()
  File "api.py", line 49, in wrapper
    return await func(*args, **kwargs)
  File "api.py", line 217, in get_devices
    response = await self._get("devices")
  File "api.py", line 91, in wrapper
    return await func(*args, **kwargs)
  File "api.py", line 375, in _get
    await self.identity_api.login()
  File "api.py", line 154, in login
    response = await self.get_token.login_async(
  File "lib/python3.10/site-packages/auth0/asyncify.py", line 10, in closure
    return await m(*args, **kwargs)
  File "lib/python3.10/site-packages/auth0/authentication/get_token.py", line 156, in login
    return self.authenticated_post(
  File "lib/python3.10/site-packages/auth0/authentication/base.py", line 59, in authenticated_post
    url, data=self._add_client_authentication(data), headers=headers
  File "lib/python3.10/site-packages/auth0/authentication/base.py", line 45, in _add_client_authentication
    return add_client_authentication(
  File "lib/python3.10/site-packages/auth0/authentication/client_authentication.py", line 61, in add_client_authentication
    authenticated_payload["client_assertion"] = create_client_assertion_jwt(
  File "lib/python3.10/site-packages/auth0/authentication/client_authentication.py", line 23, in create_client_assertion_jwt
    return jwt.encode(
  File "lib/python3.10/site-packages/jwt/api_jwt.py", line 73, in encode
    return api_jws.encode(
  File "lib/python3.10/site-packages/jwt/api_jws.py", line 159, in encode
    alg_obj = self.get_algorithm_by_name(algorithm_)
  File "lib/python3.10/site-packages/jwt/api_jws.py", line 101, in get_algorithm_by_name
    raise NotImplementedError("Algorithm not supported") from e
NotImplementedError: Algorithm not supported
```

### auth0-python version

4.2.0

### Python version

3.10

Discussion:

Patch:
diff --git a/auth0/asyncify.py b/auth0/asyncify.py
index d57bc70..091d049 100644
--- a/auth0/asyncify.py
+++ b/auth0/asyncify.py
@@ -1,5 +1,7 @@
 import aiohttp
 
+from auth0.authentication.base import AuthenticationBase
+from auth0.rest import RestClientOptions
 from auth0.rest_async import AsyncRestClient
 
 
@@ -19,7 +21,7 @@ def asyncify(cls):
         if callable(getattr(cls, func)) and not func.startswith("_")
     ]
 
-    class AsyncClient(cls):
+    class AsyncManagementClient(cls):
         def __init__(
             self,
             domain,
@@ -29,40 +31,47 @@ def asyncify(cls):
             protocol="https",
             rest_options=None,
         ):
-            if token is None:
-                # Wrap the auth client
-                super().__init__(domain, telemetry, timeout, protocol)
-            else:
-                # Wrap the mngtmt client
-                super().__init__(
-                    domain, token, telemetry, timeout, protocol, rest_options
-                )
+            super().__init__(domain, token, telemetry, timeout, protocol, rest_options)
             self.client = AsyncRestClient(
                 jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options
             )
 
-    class Wrapper(cls):
+    class AsyncAuthenticationClient(cls):
         def __init__(
             self,
             domain,
-            token=None,
+            client_id,
+            client_secret=None,
+            client_assertion_signing_key=None,
+            client_assertion_signing_alg=None,
             telemetry=True,
             timeout=5.0,
             protocol="https",
-            rest_options=None,
         ):
-            if token is None:
-                # Wrap the auth client
-                super().__init__(domain, telemetry, timeout, protocol)
-            else:
-                # Wrap the mngtmt client
-                super().__init__(
-                    domain, token, telemetry, timeout, protocol, rest_options
-                )
-
-            self._async_client = AsyncClient(
-                domain, token, telemetry, timeout, protocol, rest_options
+            super().__init__(
+                domain,
+                client_id,
+                client_secret,
+                client_assertion_signing_key,
+                client_assertion_signing_alg,
+                telemetry,
+                timeout,
+                protocol,
+            )
+            self.client = AsyncRestClient(
+                None,
+                options=RestClientOptions(
+                    telemetry=telemetry, timeout=timeout, retries=0
+                ),
             )
+
+    class Wrapper(cls):
+        def __init__(self, *args, **kwargs):
+            super().__init__(*args, **kwargs)
+            if AuthenticationBase in cls.__bases__:
+                self._async_client = AsyncAuthenticationClient(*args, **kwargs)
+            else:
+                self._async_client = AsyncManagementClient(*args, **kwargs)
             for method in methods:
                 setattr(
                     self,


Test patch:
diff --git a/auth0/test_async/test_asyncify.py b/auth0/test_async/test_asyncify.py
index 2f98102..8a80bef 100644
--- a/auth0/test_async/test_asyncify.py
+++ b/auth0/test_async/test_asyncify.py
@@ -12,9 +12,11 @@ from aioresponses import CallbackResult, aioresponses
 from callee import Attrs
 
 from auth0.asyncify import asyncify
+from auth0.authentication import GetToken
 from auth0.management import Clients, Guardian, Jobs
 
 clients = re.compile(r"^https://example\.com/api/v2/clients.*")
+token = re.compile(r"^https://example\.com/oauth/token.*")
 factors = re.compile(r"^https://example\.com/api/v2/guardian/factors.*")
 users_imports = re.compile(r"^https://example\.com/api/v2/jobs/users-imports.*")
 payload = {"foo": "bar"}
@@ -84,6 +86,31 @@ class TestAsyncify(getattr(unittest, "IsolatedAsyncioTestCase", object)):
             timeout=ANY,
         )
 
+    @aioresponses()
+    async def test_post_auth(self, mocked):
+        callback, mock = get_callback()
+        mocked.post(token, callback=callback)
+        c = asyncify(GetToken)("example.com", "cid", client_secret="clsec")
+        self.assertEqual(
+            await c.login_async(username="usrnm", password="pswd"), payload
+        )
+        mock.assert_called_with(
+            Attrs(path="/oauth/token"),
+            allow_redirects=True,
+            json={
+                "client_id": "cid",
+                "username": "usrnm",
+                "password": "pswd",
+                "realm": None,
+                "scope": None,
+                "audience": None,
+                "grant_type": "http://auth0.com/oauth/grant-type/password-realm",
+                "client_secret": "clsec",
+            },
+            headers={i: headers[i] for i in headers if i != "Authorization"},
+            timeout=ANY,
+        )
+
     @aioresponses()
     async def test_file_post(self, mocked):
         callback, mock = get_callback()