11import aiohttp
22
3+ from auth0 .authentication .base import AuthenticationBase
4+ from auth0 .rest import RestClientOptions
35from auth0 .rest_async import AsyncRestClient
46
57
@@ -19,7 +21,7 @@ def asyncify(cls):
1921 if callable (getattr (cls , func )) and not func .startswith ("_" )
2022 ]
2123
22- class AsyncClient (cls ):
24+ class AsyncManagementClient (cls ):
2325 def __init__ (
2426 self ,
2527 domain ,
@@ -29,40 +31,47 @@ def __init__(
2931 protocol = "https" ,
3032 rest_options = None ,
3133 ):
32- if token is None :
33- # Wrap the auth client
34- super ().__init__ (domain , telemetry , timeout , protocol )
35- else :
36- # Wrap the mngtmt client
37- super ().__init__ (
38- domain , token , telemetry , timeout , protocol , rest_options
39- )
34+ super ().__init__ (domain , token , telemetry , timeout , protocol , rest_options )
4035 self .client = AsyncRestClient (
4136 jwt = token , telemetry = telemetry , timeout = timeout , options = rest_options
4237 )
4338
44- class Wrapper (cls ):
39+ class AsyncAuthenticationClient (cls ):
4540 def __init__ (
4641 self ,
4742 domain ,
48- token = None ,
43+ client_id ,
44+ client_secret = None ,
45+ client_assertion_signing_key = None ,
46+ client_assertion_signing_alg = None ,
4947 telemetry = True ,
5048 timeout = 5.0 ,
5149 protocol = "https" ,
52- rest_options = None ,
5350 ):
54- if token is None :
55- # Wrap the auth client
56- super ().__init__ (domain , telemetry , timeout , protocol )
57- else :
58- # Wrap the mngtmt client
59- super ().__init__ (
60- domain , token , telemetry , timeout , protocol , rest_options
61- )
62-
63- self ._async_client = AsyncClient (
64- domain , token , telemetry , timeout , protocol , rest_options
51+ super ().__init__ (
52+ domain ,
53+ client_id ,
54+ client_secret ,
55+ client_assertion_signing_key ,
56+ client_assertion_signing_alg ,
57+ telemetry ,
58+ timeout ,
59+ protocol ,
60+ )
61+ self .client = AsyncRestClient (
62+ None ,
63+ options = RestClientOptions (
64+ telemetry = telemetry , timeout = timeout , retries = 0
65+ ),
6566 )
67+
68+ class Wrapper (cls ):
69+ def __init__ (self , * args , ** kwargs ):
70+ super ().__init__ (* args , ** kwargs )
71+ if AuthenticationBase in cls .__bases__ :
72+ self ._async_client = AsyncAuthenticationClient (* args , ** kwargs )
73+ else :
74+ self ._async_client = AsyncManagementClient (* args , ** kwargs )
6675 for method in methods :
6776 setattr (
6877 self ,
0 commit comments