1
1
import aiohttp
2
2
3
+ from auth0 .authentication .base import AuthenticationBase
4
+ from auth0 .rest import RestClientOptions
3
5
from auth0 .rest_async import AsyncRestClient
4
6
5
7
@@ -19,7 +21,7 @@ def asyncify(cls):
19
21
if callable (getattr (cls , func )) and not func .startswith ("_" )
20
22
]
21
23
22
- class AsyncClient (cls ):
24
+ class AsyncManagementClient (cls ):
23
25
def __init__ (
24
26
self ,
25
27
domain ,
@@ -29,40 +31,47 @@ def __init__(
29
31
protocol = "https" ,
30
32
rest_options = None ,
31
33
):
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 )
40
35
self .client = AsyncRestClient (
41
36
jwt = token , telemetry = telemetry , timeout = timeout , options = rest_options
42
37
)
43
38
44
- class Wrapper (cls ):
39
+ class AsyncAuthenticationClient (cls ):
45
40
def __init__ (
46
41
self ,
47
42
domain ,
48
- token = None ,
43
+ client_id ,
44
+ client_secret = None ,
45
+ client_assertion_signing_key = None ,
46
+ client_assertion_signing_alg = None ,
49
47
telemetry = True ,
50
48
timeout = 5.0 ,
51
49
protocol = "https" ,
52
- rest_options = None ,
53
50
):
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
+ ),
65
66
)
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 )
66
75
for method in methods :
67
76
setattr (
68
77
self ,
0 commit comments