Debian Codegraph @

src/auth0/management/client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 from __future__ import annotations
4
5 import typing
6
7 import httpx
8 from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9 from .core.logging import LogConfig, Logger
10 from .environment import Auth0Environment
11
12 if typing.TYPE_CHECKING:
13 from .actions.client import ActionsClient, AsyncActionsClient
14 from .anomaly.client import AnomalyClient, AsyncAnomalyClient
15 from .attack_protection.client import AsyncAttackProtectionClient, AttackProtectionClient
16 from .branding.client import AsyncBrandingClient, BrandingClient
17 from .client_grants.client import AsyncClientGrantsClient, ClientGrantsClient
18 from .clients.client import AsyncClientsClient, ClientsClient
19 from .connection_profiles.client import AsyncConnectionProfilesClient, ConnectionProfilesClient
20 from .connections.client import AsyncConnectionsClient, ConnectionsClient
21 from .custom_domains.client import AsyncCustomDomainsClient, CustomDomainsClient
22 from .device_credentials.client import AsyncDeviceCredentialsClient, DeviceCredentialsClient
23 from .email_templates.client import AsyncEmailTemplatesClient, EmailTemplatesClient
24 from .emails.client import AsyncEmailsClient, EmailsClient
25 from .event_streams.client import AsyncEventStreamsClient, EventStreamsClient
26 from .events.client import AsyncEventsClient, EventsClient
27 from .flows.client import AsyncFlowsClient, FlowsClient
28 from .forms.client import AsyncFormsClient, FormsClient
29 from .groups.client import AsyncGroupsClient, GroupsClient
30 from .guardian.client import AsyncGuardianClient, GuardianClient
31 from .hooks.client import AsyncHooksClient, HooksClient
32 from .jobs.client import AsyncJobsClient, JobsClient
33 from .keys.client import AsyncKeysClient, KeysClient
34 from .log_streams.client import AsyncLogStreamsClient, LogStreamsClient
35 from .logs.client import AsyncLogsClient, LogsClient
36 from .network_acls.client import AsyncNetworkAclsClient, NetworkAclsClient
37 from .organizations.client import AsyncOrganizationsClient, OrganizationsClient
38 from .prompts.client import AsyncPromptsClient, PromptsClient
39 from .rate_limit_policies.client import AsyncRateLimitPoliciesClient, RateLimitPoliciesClient
40 from .refresh_tokens.client import AsyncRefreshTokensClient, RefreshTokensClient
41 from .resource_servers.client import AsyncResourceServersClient, ResourceServersClient
42 from .risk_assessments.client import AsyncRiskAssessmentsClient, RiskAssessmentsClient
43 from .roles.client import AsyncRolesClient, RolesClient
44 from .rules.client import AsyncRulesClient, RulesClient
45 from .rules_configs.client import AsyncRulesConfigsClient, RulesConfigsClient
46 from .self_service_profiles.client import AsyncSelfServiceProfilesClient, SelfServiceProfilesClient
47 from .sessions.client import AsyncSessionsClient, SessionsClient
48 from .stats.client import AsyncStatsClient, StatsClient
49 from .supplemental_signals.client import AsyncSupplementalSignalsClient, SupplementalSignalsClient
50 from .tenants.client import AsyncTenantsClient, TenantsClient
51 from .tickets.client import AsyncTicketsClient, TicketsClient
52 from .token_exchange_profiles.client import AsyncTokenExchangeProfilesClient, TokenExchangeProfilesClient
53 from .user_attribute_profiles.client import AsyncUserAttributeProfilesClient, UserAttributeProfilesClient
54 from .user_blocks.client import AsyncUserBlocksClient, UserBlocksClient
55 from .user_grants.client import AsyncUserGrantsClient, UserGrantsClient
56 from .users.client import AsyncUsersClient, UsersClient
57 from .verifiable_credentials.client import AsyncVerifiableCredentialsClient, VerifiableCredentialsClient
58
59
60 class Auth0:
61 """
62 Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
63
64 Parameters
65 ----------
66 base_url : typing.Optional[str]
67 The base url to use for requests from the client.
68
69 environment : Auth0Environment
70 The environment to use for requests from the client. from .environment import Auth0Environment
71
72
73
74 Defaults to Auth0Environment.DEFAULT
75
76
77
78 tenant_domain : typing.Optional[str]
79 Server URL variable for 'tenantDomain'. Defaults to '{TENANT}.auth0.com'.
80
81 token : typing.Union[str, typing.Callable[[], str]]
82 headers : typing.Optional[typing.Dict[str, str]]
83 Additional headers to send with every request.
84
85 timeout : typing.Optional[float]
86 The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
87
88 max_retries : typing.Optional[int]
89 The default maximum number of retries for failed requests. Defaults to 2. Per-request `max_retries` in `request_options` takes precedence over this value.
90
91 stream_reconnection_enabled : typing.Optional[bool]
92 Whether to automatically reconnect on stream disconnection for resumable streaming endpoints. Defaults to True. Per-request `stream_reconnection_enabled` in `request_options` takes precedence over this value.
93
94 max_stream_reconnection_attempts : typing.Optional[int]
95 The maximum number of reconnection attempts for resumable streaming endpoints. Defaults to no limit. Per-request `max_stream_reconnection_attempts` in `request_options` takes precedence over this value.
96
97 follow_redirects : typing.Optional[bool]
98 Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
99
100 httpx_client : typing.Optional[httpx.Client]
101 The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
102
103 logging : typing.Optional[typing.Union[LogConfig, Logger]]
104 Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
105
106 Examples
107 --------
108 from auth0 import Auth0
109
110 client = Auth0(
111 token="YOUR_TOKEN",
112 )
113 """
114
115 def __init__(
116 self,
117 *,
118 base_url: typing.Optional[str] = None,
119 environment: Auth0Environment = Auth0Environment.DEFAULT,
120 tenant_domain: typing.Optional[str] = None,
121 token: typing.Union[str, typing.Callable[[], str]],
122 headers: typing.Optional[typing.Dict[str, str]] = None,
123 timeout: typing.Optional[float] = None,
124 max_retries: typing.Optional[int] = None,
125 stream_reconnection_enabled: typing.Optional[bool] = None,
126 max_stream_reconnection_attempts: typing.Optional[int] = None,
127 follow_redirects: typing.Optional[bool] = True,
128 httpx_client: typing.Optional[httpx.Client] = None,
129 logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
130 ):
131 _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
132 _defaulted_max_retries = max_retries if max_retries is not None else 2
133 if tenant_domain is not None:
134 _tenant_domain = tenant_domain if tenant_domain is not None else "{TENANT}.auth0.com"
135 base_url = "https://{tenantDomain}/api/v2".format(tenantDomain=_tenant_domain)
136 self._client_wrapper = SyncClientWrapper(
137 base_url=_get_base_url(base_url=base_url, environment=environment),
138 token=token,
139 headers=headers,
140 httpx_client=httpx_client
141 if httpx_client is not None
142 else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
143 if follow_redirects is not None
144 else httpx.Client(timeout=_defaulted_timeout),
145 timeout=_defaulted_timeout,
146 max_retries=_defaulted_max_retries,
147 stream_reconnection_enabled=stream_reconnection_enabled,
148 max_stream_reconnection_attempts=max_stream_reconnection_attempts,
149 logging=logging,
150 )
151 self._actions: typing.Optional[ActionsClient] = None
152 self._branding: typing.Optional[BrandingClient] = None
153 self._client_grants: typing.Optional[ClientGrantsClient] = None
154 self._clients: typing.Optional[ClientsClient] = None
155 self._connection_profiles: typing.Optional[ConnectionProfilesClient] = None
156 self._connections: typing.Optional[ConnectionsClient] = None
157 self._custom_domains: typing.Optional[CustomDomainsClient] = None
158 self._device_credentials: typing.Optional[DeviceCredentialsClient] = None
159 self._email_templates: typing.Optional[EmailTemplatesClient] = None
160 self._event_streams: typing.Optional[EventStreamsClient] = None
161 self._events: typing.Optional[EventsClient] = None
162 self._flows: typing.Optional[FlowsClient] = None
163 self._forms: typing.Optional[FormsClient] = None
164 self._user_grants: typing.Optional[UserGrantsClient] = None
165 self._groups: typing.Optional[GroupsClient] = None
166 self._hooks: typing.Optional[HooksClient] = None
167 self._jobs: typing.Optional[JobsClient] = None
168 self._log_streams: typing.Optional[LogStreamsClient] = None
169 self._logs: typing.Optional[LogsClient] = None
170 self._network_acls: typing.Optional[NetworkAclsClient] = None
171 self._organizations: typing.Optional[OrganizationsClient] = None
172 self._prompts: typing.Optional[PromptsClient] = None
173 self._rate_limit_policies: typing.Optional[RateLimitPoliciesClient] = None
174 self._refresh_tokens: typing.Optional[RefreshTokensClient] = None
175 self._resource_servers: typing.Optional[ResourceServersClient] = None
176 self._roles: typing.Optional[RolesClient] = None
177 self._rules: typing.Optional[RulesClient] = None
178 self._rules_configs: typing.Optional[RulesConfigsClient] = None
179 self._self_service_profiles: typing.Optional[SelfServiceProfilesClient] = None
180 self._sessions: typing.Optional[SessionsClient] = None
181 self._stats: typing.Optional[StatsClient] = None
182 self._supplemental_signals: typing.Optional[SupplementalSignalsClient] = None
183 self._tickets: typing.Optional[TicketsClient] = None
184 self._token_exchange_profiles: typing.Optional[TokenExchangeProfilesClient] = None
185 self._user_attribute_profiles: typing.Optional[UserAttributeProfilesClient] = None
186 self._user_blocks: typing.Optional[UserBlocksClient] = None
187 self._users: typing.Optional[UsersClient] = None
188 self._anomaly: typing.Optional[AnomalyClient] = None
189 self._attack_protection: typing.Optional[AttackProtectionClient] = None
190 self._emails: typing.Optional[EmailsClient] = None
191 self._guardian: typing.Optional[GuardianClient] = None
192 self._keys: typing.Optional[KeysClient] = None
193 self._risk_assessments: typing.Optional[RiskAssessmentsClient] = None
194 self._tenants: typing.Optional[TenantsClient] = None
195 self._verifiable_credentials: typing.Optional[VerifiableCredentialsClient] = None
196
197 @property
198 def actions(self):
199 if self._actions is None:
200 from .actions.client import ActionsClient # noqa: E402
201
202 self._actions = ActionsClient(client_wrapper=self._client_wrapper)
203 return self._actions
204
205 @property
206 def branding(self):
207 if self._branding is None:
208 from .branding.client import BrandingClient # noqa: E402
209
210 self._branding = BrandingClient(client_wrapper=self._client_wrapper)
211 return self._branding
212
213 @property
214 def client_grants(self):
215 if self._client_grants is None:
216 from .client_grants.client import ClientGrantsClient # noqa: E402
217
218 self._client_grants = ClientGrantsClient(client_wrapper=self._client_wrapper)
219 return self._client_grants
220
221 @property
222 def clients(self):
223 if self._clients is None:
224 from .clients.client import ClientsClient # noqa: E402
225
226 self._clients = ClientsClient(client_wrapper=self._client_wrapper)
227 return self._clients
228
229 @property
230 def connection_profiles(self):
231 if self._connection_profiles is None:
232 from .connection_profiles.client import ConnectionProfilesClient # noqa: E402
233
234 self._connection_profiles = ConnectionProfilesClient(client_wrapper=self._client_wrapper)
235 return self._connection_profiles
236
237 @property
238 def connections(self):
239 if self._connections is None:
240 from .connections.client import ConnectionsClient # noqa: E402
241
242 self._connections = ConnectionsClient(client_wrapper=self._client_wrapper)
243 return self._connections
244
245 @property
246 def custom_domains(self):
247 if self._custom_domains is None:
248 from .custom_domains.client import CustomDomainsClient # noqa: E402
249
250 self._custom_domains = CustomDomainsClient(client_wrapper=self._client_wrapper)
251 return self._custom_domains
252
253 @property
254 def device_credentials(self):
255 if self._device_credentials is None:
256 from .device_credentials.client import DeviceCredentialsClient # noqa: E402
257
258 self._device_credentials = DeviceCredentialsClient(client_wrapper=self._client_wrapper)
259 return self._device_credentials
260
261 @property
262 def email_templates(self):
263 if self._email_templates is None:
264 from .email_templates.client import EmailTemplatesClient # noqa: E402
265
266 self._email_templates = EmailTemplatesClient(client_wrapper=self._client_wrapper)
267 return self._email_templates
268
269 @property
270 def event_streams(self):
271 if self._event_streams is None:
272 from .event_streams.client import EventStreamsClient # noqa: E402
273
274 self._event_streams = EventStreamsClient(client_wrapper=self._client_wrapper)
275 return self._event_streams
276
277 @property
278 def events(self):
279 if self._events is None:
280 from .events.client import EventsClient # noqa: E402
281
282 self._events = EventsClient(client_wrapper=self._client_wrapper)
283 return self._events
284
285 @property
286 def flows(self):
287 if self._flows is None:
288 from .flows.client import FlowsClient # noqa: E402
289
290 self._flows = FlowsClient(client_wrapper=self._client_wrapper)
291 return self._flows
292
293 @property
294 def forms(self):
295 if self._forms is None:
296 from .forms.client import FormsClient # noqa: E402
297
298 self._forms = FormsClient(client_wrapper=self._client_wrapper)
299 return self._forms
300
301 @property
302 def user_grants(self):
303 if self._user_grants is None:
304 from .user_grants.client import UserGrantsClient # noqa: E402
305
306 self._user_grants = UserGrantsClient(client_wrapper=self._client_wrapper)
307 return self._user_grants
308
309 @property
310 def groups(self):
311 if self._groups is None:
312 from .groups.client import GroupsClient # noqa: E402
313
314 self._groups = GroupsClient(client_wrapper=self._client_wrapper)
315 return self._groups
316
317 @property
318 def hooks(self):
319 if self._hooks is None:
320 from .hooks.client import HooksClient # noqa: E402
321
322 self._hooks = HooksClient(client_wrapper=self._client_wrapper)
323 return self._hooks
324
325 @property
326 def jobs(self):
327 if self._jobs is None:
328 from .jobs.client import JobsClient # noqa: E402
329
330 self._jobs = JobsClient(client_wrapper=self._client_wrapper)
331 return self._jobs
332
333 @property
334 def log_streams(self):
335 if self._log_streams is None:
336 from .log_streams.client import LogStreamsClient # noqa: E402
337
338 self._log_streams = LogStreamsClient(client_wrapper=self._client_wrapper)
339 return self._log_streams
340
341 @property
342 def logs(self):
343 if self._logs is None:
344 from .logs.client import LogsClient # noqa: E402
345
346 self._logs = LogsClient(client_wrapper=self._client_wrapper)
347 return self._logs
348
349 @property
350 def network_acls(self):
351 if self._network_acls is None:
352 from .network_acls.client import NetworkAclsClient # noqa: E402
353
354 self._network_acls = NetworkAclsClient(client_wrapper=self._client_wrapper)
355 return self._network_acls
356
357 @property
358 def organizations(self):
359 if self._organizations is None:
360 from .organizations.client import OrganizationsClient # noqa: E402
361
362 self._organizations = OrganizationsClient(client_wrapper=self._client_wrapper)
363 return self._organizations
364
365 @property
366 def prompts(self):
367 if self._prompts is None:
368 from .prompts.client import PromptsClient # noqa: E402
369
370 self._prompts = PromptsClient(client_wrapper=self._client_wrapper)
371 return self._prompts
372
373 @property
374 def rate_limit_policies(self):
375 if self._rate_limit_policies is None:
376 from .rate_limit_policies.client import RateLimitPoliciesClient # noqa: E402
377
378 self._rate_limit_policies = RateLimitPoliciesClient(client_wrapper=self._client_wrapper)
379 return self._rate_limit_policies
380
381 @property
382 def refresh_tokens(self):
383 if self._refresh_tokens is None:
384 from .refresh_tokens.client import RefreshTokensClient # noqa: E402
385
386 self._refresh_tokens = RefreshTokensClient(client_wrapper=self._client_wrapper)
387 return self._refresh_tokens
388
389 @property
390 def resource_servers(self):
391 if self._resource_servers is None:
392 from .resource_servers.client import ResourceServersClient # noqa: E402
393
394 self._resource_servers = ResourceServersClient(client_wrapper=self._client_wrapper)
395 return self._resource_servers
396
397 @property
398 def roles(self):
399 if self._roles is None:
400 from .roles.client import RolesClient # noqa: E402
401
402 self._roles = RolesClient(client_wrapper=self._client_wrapper)
403 return self._roles
404
405 @property
406 def rules(self):
407 if self._rules is None:
408 from .rules.client import RulesClient # noqa: E402
409
410 self._rules = RulesClient(client_wrapper=self._client_wrapper)
411 return self._rules
412
413 @property
414 def rules_configs(self):
415 if self._rules_configs is None:
416 from .rules_configs.client import RulesConfigsClient # noqa: E402
417
418 self._rules_configs = RulesConfigsClient(client_wrapper=self._client_wrapper)
419 return self._rules_configs
420
421 @property
422 def self_service_profiles(self):
423 if self._self_service_profiles is None:
424 from .self_service_profiles.client import SelfServiceProfilesClient # noqa: E402
425
426 self._self_service_profiles = SelfServiceProfilesClient(client_wrapper=self._client_wrapper)
427 return self._self_service_profiles
428
429 @property
430 def sessions(self):
431 if self._sessions is None:
432 from .sessions.client import SessionsClient # noqa: E402
433
434 self._sessions = SessionsClient(client_wrapper=self._client_wrapper)
435 return self._sessions
436
437 @property
438 def stats(self):
439 if self._stats is None:
440 from .stats.client import StatsClient # noqa: E402
441
442 self._stats = StatsClient(client_wrapper=self._client_wrapper)
443 return self._stats
444
445 @property
446 def supplemental_signals(self):
447 if self._supplemental_signals is None:
448 from .supplemental_signals.client import SupplementalSignalsClient # noqa: E402
449
450 self._supplemental_signals = SupplementalSignalsClient(client_wrapper=self._client_wrapper)
451 return self._supplemental_signals
452
453 @property
454 def tickets(self):
455 if self._tickets is None:
456 from .tickets.client import TicketsClient # noqa: E402
457
458 self._tickets = TicketsClient(client_wrapper=self._client_wrapper)
459 return self._tickets
460
461 @property
462 def token_exchange_profiles(self):
463 if self._token_exchange_profiles is None:
464 from .token_exchange_profiles.client import TokenExchangeProfilesClient # noqa: E402
465
466 self._token_exchange_profiles = TokenExchangeProfilesClient(client_wrapper=self._client_wrapper)
467 return self._token_exchange_profiles
468
469 @property
470 def user_attribute_profiles(self):
471 if self._user_attribute_profiles is None:
472 from .user_attribute_profiles.client import UserAttributeProfilesClient # noqa: E402
473
474 self._user_attribute_profiles = UserAttributeProfilesClient(client_wrapper=self._client_wrapper)
475 return self._user_attribute_profiles
476
477 @property
478 def user_blocks(self):
479 if self._user_blocks is None:
480 from .user_blocks.client import UserBlocksClient # noqa: E402
481
482 self._user_blocks = UserBlocksClient(client_wrapper=self._client_wrapper)
483 return self._user_blocks
484
485 @property
486 def users(self):
487 if self._users is None:
488 from .users.client import UsersClient # noqa: E402
489
490 self._users = UsersClient(client_wrapper=self._client_wrapper)
491 return self._users
492
493 @property
494 def anomaly(self):
495 if self._anomaly is None:
496 from .anomaly.client import AnomalyClient # noqa: E402
497
498 self._anomaly = AnomalyClient(client_wrapper=self._client_wrapper)
499 return self._anomaly
500
501 @property
502 def attack_protection(self):
503 if self._attack_protection is None:
504 from .attack_protection.client import AttackProtectionClient # noqa: E402
505
506 self._attack_protection = AttackProtectionClient(client_wrapper=self._client_wrapper)
507 return self._attack_protection
508
509 @property
510 def emails(self):
511 if self._emails is None:
512 from .emails.client import EmailsClient # noqa: E402
513
514 self._emails = EmailsClient(client_wrapper=self._client_wrapper)
515 return self._emails
516
517 @property
518 def guardian(self):
519 if self._guardian is None:
520 from .guardian.client import GuardianClient # noqa: E402
521
522 self._guardian = GuardianClient(client_wrapper=self._client_wrapper)
523 return self._guardian
524
525 @property
526 def keys(self):
527 if self._keys is None:
528 from .keys.client import KeysClient # noqa: E402
529
530 self._keys = KeysClient(client_wrapper=self._client_wrapper)
531 return self._keys
532
533 @property
534 def risk_assessments(self):
535 if self._risk_assessments is None:
536 from .risk_assessments.client import RiskAssessmentsClient # noqa: E402
537
538 self._risk_assessments = RiskAssessmentsClient(client_wrapper=self._client_wrapper)
539 return self._risk_assessments
540
541 @property
542 def tenants(self):
543 if self._tenants is None:
544 from .tenants.client import TenantsClient # noqa: E402
545
546 self._tenants = TenantsClient(client_wrapper=self._client_wrapper)
547 return self._tenants
548
549 @property
550 def verifiable_credentials(self):
551 if self._verifiable_credentials is None:
552 from .verifiable_credentials.client import VerifiableCredentialsClient # noqa: E402
553
554 self._verifiable_credentials = VerifiableCredentialsClient(client_wrapper=self._client_wrapper)
555 return self._verifiable_credentials
556
557
558 def _make_default_async_client(
559 timeout: typing.Optional[float],
560 follow_redirects: typing.Optional[bool],
561 ) -> httpx.AsyncClient:
562 try:
563 import httpx_aiohttp # type: ignore[import-not-found]
564 except ImportError:
565 pass
566 else:
567 if follow_redirects is not None:
568 return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout, follow_redirects=follow_redirects)
569 return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout)
570
571 if follow_redirects is not None:
572 return httpx.AsyncClient(timeout=timeout, follow_redirects=follow_redirects)
573 return httpx.AsyncClient(timeout=timeout)
574
575
576 class AsyncAuth0:
577 """
578 Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
579
580 Parameters
581 ----------
582 base_url : typing.Optional[str]
583 The base url to use for requests from the client.
584
585 environment : Auth0Environment
586 The environment to use for requests from the client. from .environment import Auth0Environment
587
588
589
590 Defaults to Auth0Environment.DEFAULT
591
592
593
594 tenant_domain : typing.Optional[str]
595 Server URL variable for 'tenantDomain'. Defaults to '{TENANT}.auth0.com'.
596
597 token : typing.Union[str, typing.Callable[[], str]]
598 headers : typing.Optional[typing.Dict[str, str]]
599 Additional headers to send with every request.
600
601 async_token : typing.Optional[typing.Callable[[], typing.Awaitable[str]]]
602 An async callable that returns a bearer token. Use this when token acquisition involves async I/O (e.g., refreshing tokens via an async HTTP client). When provided, this is used instead of the synchronous token for async requests.
603
604 timeout : typing.Optional[float]
605 The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
606
607 max_retries : typing.Optional[int]
608 The default maximum number of retries for failed requests. Defaults to 2. Per-request `max_retries` in `request_options` takes precedence over this value.
609
610 stream_reconnection_enabled : typing.Optional[bool]
611 Whether to automatically reconnect on stream disconnection for resumable streaming endpoints. Defaults to True. Per-request `stream_reconnection_enabled` in `request_options` takes precedence over this value.
612
613 max_stream_reconnection_attempts : typing.Optional[int]
614 The maximum number of reconnection attempts for resumable streaming endpoints. Defaults to no limit. Per-request `max_stream_reconnection_attempts` in `request_options` takes precedence over this value.
615
616 follow_redirects : typing.Optional[bool]
617 Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
618
619 httpx_client : typing.Optional[httpx.AsyncClient]
620 The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
621
622 logging : typing.Optional[typing.Union[LogConfig, Logger]]
623 Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
624
625 Examples
626 --------
627 from auth0 import AsyncAuth0
628
629 client = AsyncAuth0(
630 token="YOUR_TOKEN",
631 )
632 """
633
634 def __init__(
635 self,
636 *,
637 base_url: typing.Optional[str] = None,
638 environment: Auth0Environment = Auth0Environment.DEFAULT,
639 tenant_domain: typing.Optional[str] = None,
640 token: typing.Union[str, typing.Callable[[], str]],
641 headers: typing.Optional[typing.Dict[str, str]] = None,
642 async_token: typing.Optional[typing.Callable[[], typing.Awaitable[str]]] = None,
643 timeout: typing.Optional[float] = None,
644 max_retries: typing.Optional[int] = None,
645 stream_reconnection_enabled: typing.Optional[bool] = None,
646 max_stream_reconnection_attempts: typing.Optional[int] = None,
647 follow_redirects: typing.Optional[bool] = True,
648 httpx_client: typing.Optional[httpx.AsyncClient] = None,
649 logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
650 ):
651 _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
652 _defaulted_max_retries = max_retries if max_retries is not None else 2
653 if tenant_domain is not None:
654 _tenant_domain = tenant_domain if tenant_domain is not None else "{TENANT}.auth0.com"
655 base_url = "https://{tenantDomain}/api/v2".format(tenantDomain=_tenant_domain)
656 self._client_wrapper = AsyncClientWrapper(
657 base_url=_get_base_url(base_url=base_url, environment=environment),
658 token=token,
659 headers=headers,
660 async_token=async_token,
661 httpx_client=httpx_client
662 if httpx_client is not None
663 else _make_default_async_client(timeout=_defaulted_timeout, follow_redirects=follow_redirects),
664 timeout=_defaulted_timeout,
665 max_retries=_defaulted_max_retries,
666 stream_reconnection_enabled=stream_reconnection_enabled,
667 max_stream_reconnection_attempts=max_stream_reconnection_attempts,
668 logging=logging,
669 )
670 self._actions: typing.Optional[AsyncActionsClient] = None
671 self._branding: typing.Optional[AsyncBrandingClient] = None
672 self._client_grants: typing.Optional[AsyncClientGrantsClient] = None
673 self._clients: typing.Optional[AsyncClientsClient] = None
674 self._connection_profiles: typing.Optional[AsyncConnectionProfilesClient] = None
675 self._connections: typing.Optional[AsyncConnectionsClient] = None
676 self._custom_domains: typing.Optional[AsyncCustomDomainsClient] = None
677 self._device_credentials: typing.Optional[AsyncDeviceCredentialsClient] = None
678 self._email_templates: typing.Optional[AsyncEmailTemplatesClient] = None
679 self._event_streams: typing.Optional[AsyncEventStreamsClient] = None
680 self._events: typing.Optional[AsyncEventsClient] = None
681 self._flows: typing.Optional[AsyncFlowsClient] = None
682 self._forms: typing.Optional[AsyncFormsClient] = None
683 self._user_grants: typing.Optional[AsyncUserGrantsClient] = None
684 self._groups: typing.Optional[AsyncGroupsClient] = None
685 self._hooks: typing.Optional[AsyncHooksClient] = None
686 self._jobs: typing.Optional[AsyncJobsClient] = None
687 self._log_streams: typing.Optional[AsyncLogStreamsClient] = None
688 self._logs: typing.Optional[AsyncLogsClient] = None
689 self._network_acls: typing.Optional[AsyncNetworkAclsClient] = None
690 self._organizations: typing.Optional[AsyncOrganizationsClient] = None
691 self._prompts: typing.Optional[AsyncPromptsClient] = None
692 self._rate_limit_policies: typing.Optional[AsyncRateLimitPoliciesClient] = None
693 self._refresh_tokens: typing.Optional[AsyncRefreshTokensClient] = None
694 self._resource_servers: typing.Optional[AsyncResourceServersClient] = None
695 self._roles: typing.Optional[AsyncRolesClient] = None
696 self._rules: typing.Optional[AsyncRulesClient] = None
697 self._rules_configs: typing.Optional[AsyncRulesConfigsClient] = None
698 self._self_service_profiles: typing.Optional[AsyncSelfServiceProfilesClient] = None
699 self._sessions: typing.Optional[AsyncSessionsClient] = None
700 self._stats: typing.Optional[AsyncStatsClient] = None
701 self._supplemental_signals: typing.Optional[AsyncSupplementalSignalsClient] = None
702 self._tickets: typing.Optional[AsyncTicketsClient] = None
703 self._token_exchange_profiles: typing.Optional[AsyncTokenExchangeProfilesClient] = None
704 self._user_attribute_profiles: typing.Optional[AsyncUserAttributeProfilesClient] = None
705 self._user_blocks: typing.Optional[AsyncUserBlocksClient] = None
706 self._users: typing.Optional[AsyncUsersClient] = None
707 self._anomaly: typing.Optional[AsyncAnomalyClient] = None
708 self._attack_protection: typing.Optional[AsyncAttackProtectionClient] = None
709 self._emails: typing.Optional[AsyncEmailsClient] = None
710 self._guardian: typing.Optional[AsyncGuardianClient] = None
711 self._keys: typing.Optional[AsyncKeysClient] = None
712 self._risk_assessments: typing.Optional[AsyncRiskAssessmentsClient] = None
713 self._tenants: typing.Optional[AsyncTenantsClient] = None
714 self._verifiable_credentials: typing.Optional[AsyncVerifiableCredentialsClient] = None
715
716 @property
717 def actions(self):
718 if self._actions is None:
719 from .actions.client import AsyncActionsClient # noqa: E402
720
721 self._actions = AsyncActionsClient(client_wrapper=self._client_wrapper)
722 return self._actions
723
724 @property
725 def branding(self):
726 if self._branding is None:
727 from .branding.client import AsyncBrandingClient # noqa: E402
728
729 self._branding = AsyncBrandingClient(client_wrapper=self._client_wrapper)
730 return self._branding
731
732 @property
733 def client_grants(self):
734 if self._client_grants is None:
735 from .client_grants.client import AsyncClientGrantsClient # noqa: E402
736
737 self._client_grants = AsyncClientGrantsClient(client_wrapper=self._client_wrapper)
738 return self._client_grants
739
740 @property
741 def clients(self):
742 if self._clients is None:
743 from .clients.client import AsyncClientsClient # noqa: E402
744
745 self._clients = AsyncClientsClient(client_wrapper=self._client_wrapper)
746 return self._clients
747
748 @property
749 def connection_profiles(self):
750 if self._connection_profiles is None:
751 from .connection_profiles.client import AsyncConnectionProfilesClient # noqa: E402
752
753 self._connection_profiles = AsyncConnectionProfilesClient(client_wrapper=self._client_wrapper)
754 return self._connection_profiles
755
756 @property
757 def connections(self):
758 if self._connections is None:
759 from .connections.client import AsyncConnectionsClient # noqa: E402
760
761 self._connections = AsyncConnectionsClient(client_wrapper=self._client_wrapper)
762 return self._connections
763
764 @property
765 def custom_domains(self):
766 if self._custom_domains is None:
767 from .custom_domains.client import AsyncCustomDomainsClient # noqa: E402
768
769 self._custom_domains = AsyncCustomDomainsClient(client_wrapper=self._client_wrapper)
770 return self._custom_domains
771
772 @property
773 def device_credentials(self):
774 if self._device_credentials is None:
775 from .device_credentials.client import AsyncDeviceCredentialsClient # noqa: E402
776
777 self._device_credentials = AsyncDeviceCredentialsClient(client_wrapper=self._client_wrapper)
778 return self._device_credentials
779
780 @property
781 def email_templates(self):
782 if self._email_templates is None:
783 from .email_templates.client import AsyncEmailTemplatesClient # noqa: E402
784
785 self._email_templates = AsyncEmailTemplatesClient(client_wrapper=self._client_wrapper)
786 return self._email_templates
787
788 @property
789 def event_streams(self):
790 if self._event_streams is None:
791 from .event_streams.client import AsyncEventStreamsClient # noqa: E402
792
793 self._event_streams = AsyncEventStreamsClient(client_wrapper=self._client_wrapper)
794 return self._event_streams
795
796 @property
797 def events(self):
798 if self._events is None:
799 from .events.client import AsyncEventsClient # noqa: E402
800
801 self._events = AsyncEventsClient(client_wrapper=self._client_wrapper)
802 return self._events
803
804 @property
805 def flows(self):
806 if self._flows is None:
807 from .flows.client import AsyncFlowsClient # noqa: E402
808
809 self._flows = AsyncFlowsClient(client_wrapper=self._client_wrapper)
810 return self._flows
811
812 @property
813 def forms(self):
814 if self._forms is None:
815 from .forms.client import AsyncFormsClient # noqa: E402
816
817 self._forms = AsyncFormsClient(client_wrapper=self._client_wrapper)
818 return self._forms
819
820 @property
821 def user_grants(self):
822 if self._user_grants is None:
823 from .user_grants.client import AsyncUserGrantsClient # noqa: E402
824
825 self._user_grants = AsyncUserGrantsClient(client_wrapper=self._client_wrapper)
826 return self._user_grants
827
828 @property
829 def groups(self):
830 if self._groups is None:
831 from .groups.client import AsyncGroupsClient # noqa: E402
832
833 self._groups = AsyncGroupsClient(client_wrapper=self._client_wrapper)
834 return self._groups
835
836 @property
837 def hooks(self):
838 if self._hooks is None:
839 from .hooks.client import AsyncHooksClient # noqa: E402
840
841 self._hooks = AsyncHooksClient(client_wrapper=self._client_wrapper)
842 return self._hooks
843
844 @property
845 def jobs(self):
846 if self._jobs is None:
847 from .jobs.client import AsyncJobsClient # noqa: E402
848
849 self._jobs = AsyncJobsClient(client_wrapper=self._client_wrapper)
850 return self._jobs
851
852 @property
853 def log_streams(self):
854 if self._log_streams is None:
855 from .log_streams.client import AsyncLogStreamsClient # noqa: E402
856
857 self._log_streams = AsyncLogStreamsClient(client_wrapper=self._client_wrapper)
858 return self._log_streams
859
860 @property
861 def logs(self):
862 if self._logs is None:
863 from .logs.client import AsyncLogsClient # noqa: E402
864
865 self._logs = AsyncLogsClient(client_wrapper=self._client_wrapper)
866 return self._logs
867
868 @property
869 def network_acls(self):
870 if self._network_acls is None:
871 from .network_acls.client import AsyncNetworkAclsClient # noqa: E402
872
873 self._network_acls = AsyncNetworkAclsClient(client_wrapper=self._client_wrapper)
874 return self._network_acls
875
876 @property
877 def organizations(self):
878 if self._organizations is None:
879 from .organizations.client import AsyncOrganizationsClient # noqa: E402
880
881 self._organizations = AsyncOrganizationsClient(client_wrapper=self._client_wrapper)
882 return self._organizations
883
884 @property
885 def prompts(self):
886 if self._prompts is None:
887 from .prompts.client import AsyncPromptsClient # noqa: E402
888
889 self._prompts = AsyncPromptsClient(client_wrapper=self._client_wrapper)
890 return self._prompts
891
892 @property
893 def rate_limit_policies(self):
894 if self._rate_limit_policies is None:
895 from .rate_limit_policies.client import AsyncRateLimitPoliciesClient # noqa: E402
896
897 self._rate_limit_policies = AsyncRateLimitPoliciesClient(client_wrapper=self._client_wrapper)
898 return self._rate_limit_policies
899
900 @property
901 def refresh_tokens(self):
902 if self._refresh_tokens is None:
903 from .refresh_tokens.client import AsyncRefreshTokensClient # noqa: E402
904
905 self._refresh_tokens = AsyncRefreshTokensClient(client_wrapper=self._client_wrapper)
906 return self._refresh_tokens
907
908 @property
909 def resource_servers(self):
910 if self._resource_servers is None:
911 from .resource_servers.client import AsyncResourceServersClient # noqa: E402
912
913 self._resource_servers = AsyncResourceServersClient(client_wrapper=self._client_wrapper)
914 return self._resource_servers
915
916 @property
917 def roles(self):
918 if self._roles is None:
919 from .roles.client import AsyncRolesClient # noqa: E402
920
921 self._roles = AsyncRolesClient(client_wrapper=self._client_wrapper)
922 return self._roles
923
924 @property
925 def rules(self):
926 if self._rules is None:
927 from .rules.client import AsyncRulesClient # noqa: E402
928
929 self._rules = AsyncRulesClient(client_wrapper=self._client_wrapper)
930 return self._rules
931
932 @property
933 def rules_configs(self):
934 if self._rules_configs is None:
935 from .rules_configs.client import AsyncRulesConfigsClient # noqa: E402
936
937 self._rules_configs = AsyncRulesConfigsClient(client_wrapper=self._client_wrapper)
938 return self._rules_configs
939
940 @property
941 def self_service_profiles(self):
942 if self._self_service_profiles is None:
943 from .self_service_profiles.client import AsyncSelfServiceProfilesClient # noqa: E402
944
945 self._self_service_profiles = AsyncSelfServiceProfilesClient(client_wrapper=self._client_wrapper)
946 return self._self_service_profiles
947
948 @property
949 def sessions(self):
950 if self._sessions is None:
951 from .sessions.client import AsyncSessionsClient # noqa: E402
952
953 self._sessions = AsyncSessionsClient(client_wrapper=self._client_wrapper)
954 return self._sessions
955
956 @property
957 def stats(self):
958 if self._stats is None:
959 from .stats.client import AsyncStatsClient # noqa: E402
960
961 self._stats = AsyncStatsClient(client_wrapper=self._client_wrapper)
962 return self._stats
963
964 @property
965 def supplemental_signals(self):
966 if self._supplemental_signals is None:
967 from .supplemental_signals.client import AsyncSupplementalSignalsClient # noqa: E402
968
969 self._supplemental_signals = AsyncSupplementalSignalsClient(client_wrapper=self._client_wrapper)
970 return self._supplemental_signals
971
972 @property
973 def tickets(self):
974 if self._tickets is None:
975 from .tickets.client import AsyncTicketsClient # noqa: E402
976
977 self._tickets = AsyncTicketsClient(client_wrapper=self._client_wrapper)
978 return self._tickets
979
980 @property
981 def token_exchange_profiles(self):
982 if self._token_exchange_profiles is None:
983 from .token_exchange_profiles.client import AsyncTokenExchangeProfilesClient # noqa: E402
984
985 self._token_exchange_profiles = AsyncTokenExchangeProfilesClient(client_wrapper=self._client_wrapper)
986 return self._token_exchange_profiles
987
988 @property
989 def user_attribute_profiles(self):
990 if self._user_attribute_profiles is None:
991 from .user_attribute_profiles.client import AsyncUserAttributeProfilesClient # noqa: E402
992
993 self._user_attribute_profiles = AsyncUserAttributeProfilesClient(client_wrapper=self._client_wrapper)
994 return self._user_attribute_profiles
995
996 @property
997 def user_blocks(self):
998 if self._user_blocks is None:
999 from .user_blocks.client import AsyncUserBlocksClient # noqa: E402
1000
1001 self._user_blocks = AsyncUserBlocksClient(client_wrapper=self._client_wrapper)
1002 return self._user_blocks
1003
1004 @property
1005 def users(self):
1006 if self._users is None:
1007 from .users.client import AsyncUsersClient # noqa: E402
1008
1009 self._users = AsyncUsersClient(client_wrapper=self._client_wrapper)
1010 return self._users
1011
1012 @property
1013 def anomaly(self):
1014 if self._anomaly is None:
1015 from .anomaly.client import AsyncAnomalyClient # noqa: E402
1016
1017 self._anomaly = AsyncAnomalyClient(client_wrapper=self._client_wrapper)
1018 return self._anomaly
1019
1020 @property
1021 def attack_protection(self):
1022 if self._attack_protection is None:
1023 from .attack_protection.client import AsyncAttackProtectionClient # noqa: E402
1024
1025 self._attack_protection = AsyncAttackProtectionClient(client_wrapper=self._client_wrapper)
1026 return self._attack_protection
1027
1028 @property
1029 def emails(self):
1030 if self._emails is None:
1031 from .emails.client import AsyncEmailsClient # noqa: E402
1032
1033 self._emails = AsyncEmailsClient(client_wrapper=self._client_wrapper)
1034 return self._emails
1035
1036 @property
1037 def guardian(self):
1038 if self._guardian is None:
1039 from .guardian.client import AsyncGuardianClient # noqa: E402
1040
1041 self._guardian = AsyncGuardianClient(client_wrapper=self._client_wrapper)
1042 return self._guardian
1043
1044 @property
1045 def keys(self):
1046 if self._keys is None:
1047 from .keys.client import AsyncKeysClient # noqa: E402
1048
1049 self._keys = AsyncKeysClient(client_wrapper=self._client_wrapper)
1050 return self._keys
1051
1052 @property
1053 def risk_assessments(self):
1054 if self._risk_assessments is None:
1055 from .risk_assessments.client import AsyncRiskAssessmentsClient # noqa: E402
1056
1057 self._risk_assessments = AsyncRiskAssessmentsClient(client_wrapper=self._client_wrapper)
1058 return self._risk_assessments
1059
1060 @property
1061 def tenants(self):
1062 if self._tenants is None:
1063 from .tenants.client import AsyncTenantsClient # noqa: E402
1064
1065 self._tenants = AsyncTenantsClient(client_wrapper=self._client_wrapper)
1066 return self._tenants
1067
1068 @property
1069 def verifiable_credentials(self):
1070 if self._verifiable_credentials is None:
1071 from .verifiable_credentials.client import AsyncVerifiableCredentialsClient # noqa: E402
1072
1073 self._verifiable_credentials = AsyncVerifiableCredentialsClient(client_wrapper=self._client_wrapper)
1074 return self._verifiable_credentials
1075
1076
1077 def _get_base_url(*, base_url: typing.Optional[str] = None, environment: Auth0Environment) -> str:
1078 if base_url is not None:
1079 return base_url
1080 elif environment is not None:
1081 return environment.value
1082 else:
1083 raise Exception("Please pass in either base_url or environment to construct the client")