| 1 |
|
| 2 |
|
| 3 |
import typing |
| 4 |
|
| 5 |
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 6 |
from ..core.request_options import RequestOptions |
| 7 |
from ..types.change_password_ticket_identity import ChangePasswordTicketIdentity |
| 8 |
from ..types.change_password_ticket_response_content import ChangePasswordTicketResponseContent |
| 9 |
from ..types.identity import Identity |
| 10 |
from ..types.verify_email_ticket_response_content import VerifyEmailTicketResponseContent |
| 11 |
from .raw_client import AsyncRawTicketsClient, RawTicketsClient |
| 12 |
|
| 13 |
|
| 14 |
OMIT = typing.cast(typing.Any, ...) |
| 15 |
|
| 16 |
|
| 17 |
class TicketsClient: |
| 18 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 19 |
self._raw_client = RawTicketsClient(client_wrapper=client_wrapper) |
| 20 |
|
| 21 |
@property |
| 22 |
def with_raw_response(self) -> RawTicketsClient: |
| 23 |
""" |
| 24 |
Retrieves a raw implementation of this client that returns raw responses. |
| 25 |
|
| 26 |
Returns |
| 27 |
------- |
| 28 |
RawTicketsClient |
| 29 |
""" |
| 30 |
return self._raw_client |
| 31 |
|
| 32 |
def verify_email( |
| 33 |
self, |
| 34 |
*, |
| 35 |
user_id: str, |
| 36 |
result_url: typing.Optional[str] = OMIT, |
| 37 |
client_id: typing.Optional[str] = OMIT, |
| 38 |
organization_id: typing.Optional[str] = OMIT, |
| 39 |
ttl_sec: typing.Optional[int] = OMIT, |
| 40 |
include_email_in_redirect: typing.Optional[bool] = OMIT, |
| 41 |
identity: typing.Optional[Identity] = OMIT, |
| 42 |
request_options: typing.Optional[RequestOptions] = None, |
| 43 |
) -> VerifyEmailTicketResponseContent: |
| 44 |
""" |
| 45 |
Create an email verification ticket for a given user. An email verification ticket is a generated URL that the user can consume to verify their email address. |
| 46 |
|
| 47 |
Parameters |
| 48 |
---------- |
| 49 |
user_id : str |
| 50 |
user_id of for whom the ticket should be created. |
| 51 |
|
| 52 |
result_url : typing.Optional[str] |
| 53 |
URL the user will be redirected to in the classic Universal Login experience once the ticket is used. Cannot be specified when using client_id or organization_id. |
| 54 |
|
| 55 |
client_id : typing.Optional[str] |
| 56 |
ID of the client (application). If provided for tenants using the New Universal Login experience, the email template and UI displays application details, and the user is prompted to redirect to the application's <a target='' href='https://auth0.com/docs/authenticate/login/auth0-universal-login/configure-default-login-routes#completing-the-password-reset-flow'>default login route</a> after the ticket is used. client_id is required to use the <a target='' href='https://auth0.com/docs/customize/actions/flows-and-triggers/post-change-password-flow'>Password Reset Post Challenge</a> trigger. |
| 57 |
|
| 58 |
organization_id : typing.Optional[str] |
| 59 |
(Optional) Organization ID – the ID of the Organization. If provided, organization parameters will be made available to the email template and organization branding will be applied to the prompt. In addition, the redirect link in the prompt will include organization_id and organization_name query string parameters. |
| 60 |
|
| 61 |
ttl_sec : typing.Optional[int] |
| 62 |
Number of seconds for which the ticket is valid before expiration. If unspecified or set to 0, this value defaults to 432000 seconds (5 days). |
| 63 |
|
| 64 |
include_email_in_redirect : typing.Optional[bool] |
| 65 |
Whether to include the email address as part of the returnUrl in the reset_email (true), or not (false). |
| 66 |
|
| 67 |
identity : typing.Optional[Identity] |
| 68 |
|
| 69 |
request_options : typing.Optional[RequestOptions] |
| 70 |
Request-specific configuration. |
| 71 |
|
| 72 |
Returns |
| 73 |
------- |
| 74 |
VerifyEmailTicketResponseContent |
| 75 |
Ticket successfully created. |
| 76 |
|
| 77 |
Examples |
| 78 |
-------- |
| 79 |
from auth0 import Auth0 |
| 80 |
|
| 81 |
client = Auth0( |
| 82 |
token="YOUR_TOKEN", |
| 83 |
) |
| 84 |
client.tickets.verify_email( |
| 85 |
user_id="user_id", |
| 86 |
) |
| 87 |
""" |
| 88 |
_response = self._raw_client.verify_email( |
| 89 |
user_id=user_id, |
| 90 |
result_url=result_url, |
| 91 |
client_id=client_id, |
| 92 |
organization_id=organization_id, |
| 93 |
ttl_sec=ttl_sec, |
| 94 |
include_email_in_redirect=include_email_in_redirect, |
| 95 |
identity=identity, |
| 96 |
request_options=request_options, |
| 97 |
) |
| 98 |
return _response.data |
| 99 |
|
| 100 |
def change_password( |
| 101 |
self, |
| 102 |
*, |
| 103 |
result_url: typing.Optional[str] = OMIT, |
| 104 |
user_id: typing.Optional[str] = OMIT, |
| 105 |
client_id: typing.Optional[str] = OMIT, |
| 106 |
organization_id: typing.Optional[str] = OMIT, |
| 107 |
connection_id: typing.Optional[str] = OMIT, |
| 108 |
email: typing.Optional[str] = OMIT, |
| 109 |
ttl_sec: typing.Optional[int] = OMIT, |
| 110 |
mark_email_as_verified: typing.Optional[bool] = OMIT, |
| 111 |
include_email_in_redirect: typing.Optional[bool] = OMIT, |
| 112 |
identity: typing.Optional[ChangePasswordTicketIdentity] = OMIT, |
| 113 |
request_options: typing.Optional[RequestOptions] = None, |
| 114 |
) -> ChangePasswordTicketResponseContent: |
| 115 |
""" |
| 116 |
Create a password change ticket for a given user. A password change ticket is a generated URL that the user can consume to start a reset password flow. |
| 117 |
|
| 118 |
Note: This endpoint does not verify the given user’s identity. If you call this endpoint within your application, you must design your application to verify the user’s identity. |
| 119 |
|
| 120 |
Parameters |
| 121 |
---------- |
| 122 |
result_url : typing.Optional[str] |
| 123 |
URL the user will be redirected to in the classic Universal Login experience once the ticket is used. Cannot be specified when using organization_id. May be specified together with client_id when the tenant has a custom password reset page enabled and a password-reset-post-challenge Action bound. |
| 124 |
|
| 125 |
user_id : typing.Optional[str] |
| 126 |
user_id of for whom the ticket should be created. |
| 127 |
|
| 128 |
client_id : typing.Optional[str] |
| 129 |
ID of the client (application). If provided for tenants using the New Universal Login experience, the email template and UI displays application details, and the user is prompted to redirect to the application's <a target='' href='https://auth0.com/docs/authenticate/login/auth0-universal-login/configure-default-login-routes#completing-the-password-reset-flow'>default login route</a> after the ticket is used. client_id is required to use the <a target='' href='https://auth0.com/docs/customize/actions/flows-and-triggers/post-change-password-flow'>Password Reset Post Challenge</a> trigger. |
| 130 |
|
| 131 |
organization_id : typing.Optional[str] |
| 132 |
(Optional) Organization ID – the ID of the Organization. If provided, organization parameters will be made available to the email template and organization branding will be applied to the prompt. In addition, the redirect link in the prompt will include organization_id and organization_name query string parameters. |
| 133 |
|
| 134 |
connection_id : typing.Optional[str] |
| 135 |
ID of the connection. If provided, allows the user to be specified using email instead of user_id. If you set this value, you must also send the email parameter. You cannot send user_id when specifying a connection_id. |
| 136 |
|
| 137 |
email : typing.Optional[str] |
| 138 |
Email address of the user for whom the tickets should be created. Requires the connection_id parameter. Cannot be specified when using user_id. |
| 139 |
|
| 140 |
ttl_sec : typing.Optional[int] |
| 141 |
Number of seconds for which the ticket is valid before expiration. If unspecified or set to 0, this value defaults to 432000 seconds (5 days). |
| 142 |
|
| 143 |
mark_email_as_verified : typing.Optional[bool] |
| 144 |
Whether to set the email_verified attribute to true (true) or whether it should not be updated (false). |
| 145 |
|
| 146 |
include_email_in_redirect : typing.Optional[bool] |
| 147 |
Whether to include the email address as part of the returnUrl in the reset_email (true), or not (false). |
| 148 |
|
| 149 |
identity : typing.Optional[ChangePasswordTicketIdentity] |
| 150 |
|
| 151 |
request_options : typing.Optional[RequestOptions] |
| 152 |
Request-specific configuration. |
| 153 |
|
| 154 |
Returns |
| 155 |
------- |
| 156 |
ChangePasswordTicketResponseContent |
| 157 |
Ticket successfully created. |
| 158 |
|
| 159 |
Examples |
| 160 |
-------- |
| 161 |
from auth0 import Auth0 |
| 162 |
|
| 163 |
client = Auth0( |
| 164 |
token="YOUR_TOKEN", |
| 165 |
) |
| 166 |
client.tickets.change_password() |
| 167 |
""" |
| 168 |
_response = self._raw_client.change_password( |
| 169 |
result_url=result_url, |
| 170 |
user_id=user_id, |
| 171 |
client_id=client_id, |
| 172 |
organization_id=organization_id, |
| 173 |
connection_id=connection_id, |
| 174 |
email=email, |
| 175 |
ttl_sec=ttl_sec, |
| 176 |
mark_email_as_verified=mark_email_as_verified, |
| 177 |
include_email_in_redirect=include_email_in_redirect, |
| 178 |
identity=identity, |
| 179 |
request_options=request_options, |
| 180 |
) |
| 181 |
return _response.data |
| 182 |
|
| 183 |
|
| 184 |
class AsyncTicketsClient: |
| 185 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 186 |
self._raw_client = AsyncRawTicketsClient(client_wrapper=client_wrapper) |
| 187 |
|
| 188 |
@property |
| 189 |
def with_raw_response(self) -> AsyncRawTicketsClient: |
| 190 |
""" |
| 191 |
Retrieves a raw implementation of this client that returns raw responses. |
| 192 |
|
| 193 |
Returns |
| 194 |
------- |
| 195 |
AsyncRawTicketsClient |
| 196 |
""" |
| 197 |
return self._raw_client |
| 198 |
|
| 199 |
async def verify_email( |
| 200 |
self, |
| 201 |
*, |
| 202 |
user_id: str, |
| 203 |
result_url: typing.Optional[str] = OMIT, |
| 204 |
client_id: typing.Optional[str] = OMIT, |
| 205 |
organization_id: typing.Optional[str] = OMIT, |
| 206 |
ttl_sec: typing.Optional[int] = OMIT, |
| 207 |
include_email_in_redirect: typing.Optional[bool] = OMIT, |
| 208 |
identity: typing.Optional[Identity] = OMIT, |
| 209 |
request_options: typing.Optional[RequestOptions] = None, |
| 210 |
) -> VerifyEmailTicketResponseContent: |
| 211 |
""" |
| 212 |
Create an email verification ticket for a given user. An email verification ticket is a generated URL that the user can consume to verify their email address. |
| 213 |
|
| 214 |
Parameters |
| 215 |
---------- |
| 216 |
user_id : str |
| 217 |
user_id of for whom the ticket should be created. |
| 218 |
|
| 219 |
result_url : typing.Optional[str] |
| 220 |
URL the user will be redirected to in the classic Universal Login experience once the ticket is used. Cannot be specified when using client_id or organization_id. |
| 221 |
|
| 222 |
client_id : typing.Optional[str] |
| 223 |
ID of the client (application). If provided for tenants using the New Universal Login experience, the email template and UI displays application details, and the user is prompted to redirect to the application's <a target='' href='https://auth0.com/docs/authenticate/login/auth0-universal-login/configure-default-login-routes#completing-the-password-reset-flow'>default login route</a> after the ticket is used. client_id is required to use the <a target='' href='https://auth0.com/docs/customize/actions/flows-and-triggers/post-change-password-flow'>Password Reset Post Challenge</a> trigger. |
| 224 |
|
| 225 |
organization_id : typing.Optional[str] |
| 226 |
(Optional) Organization ID – the ID of the Organization. If provided, organization parameters will be made available to the email template and organization branding will be applied to the prompt. In addition, the redirect link in the prompt will include organization_id and organization_name query string parameters. |
| 227 |
|
| 228 |
ttl_sec : typing.Optional[int] |
| 229 |
Number of seconds for which the ticket is valid before expiration. If unspecified or set to 0, this value defaults to 432000 seconds (5 days). |
| 230 |
|
| 231 |
include_email_in_redirect : typing.Optional[bool] |
| 232 |
Whether to include the email address as part of the returnUrl in the reset_email (true), or not (false). |
| 233 |
|
| 234 |
identity : typing.Optional[Identity] |
| 235 |
|
| 236 |
request_options : typing.Optional[RequestOptions] |
| 237 |
Request-specific configuration. |
| 238 |
|
| 239 |
Returns |
| 240 |
------- |
| 241 |
VerifyEmailTicketResponseContent |
| 242 |
Ticket successfully created. |
| 243 |
|
| 244 |
Examples |
| 245 |
-------- |
| 246 |
import asyncio |
| 247 |
|
| 248 |
from auth0 import AsyncAuth0 |
| 249 |
|
| 250 |
client = AsyncAuth0( |
| 251 |
token="YOUR_TOKEN", |
| 252 |
) |
| 253 |
|
| 254 |
|
| 255 |
async def main() -> None: |
| 256 |
await client.tickets.verify_email( |
| 257 |
user_id="user_id", |
| 258 |
) |
| 259 |
|
| 260 |
|
| 261 |
asyncio.run(main()) |
| 262 |
""" |
| 263 |
_response = await self._raw_client.verify_email( |
| 264 |
user_id=user_id, |
| 265 |
result_url=result_url, |
| 266 |
client_id=client_id, |
| 267 |
organization_id=organization_id, |
| 268 |
ttl_sec=ttl_sec, |
| 269 |
include_email_in_redirect=include_email_in_redirect, |
| 270 |
identity=identity, |
| 271 |
request_options=request_options, |
| 272 |
) |
| 273 |
return _response.data |
| 274 |
|
| 275 |
async def change_password( |
| 276 |
self, |
| 277 |
*, |
| 278 |
result_url: typing.Optional[str] = OMIT, |
| 279 |
user_id: typing.Optional[str] = OMIT, |
| 280 |
client_id: typing.Optional[str] = OMIT, |
| 281 |
organization_id: typing.Optional[str] = OMIT, |
| 282 |
connection_id: typing.Optional[str] = OMIT, |
| 283 |
email: typing.Optional[str] = OMIT, |
| 284 |
ttl_sec: typing.Optional[int] = OMIT, |
| 285 |
mark_email_as_verified: typing.Optional[bool] = OMIT, |
| 286 |
include_email_in_redirect: typing.Optional[bool] = OMIT, |
| 287 |
identity: typing.Optional[ChangePasswordTicketIdentity] = OMIT, |
| 288 |
request_options: typing.Optional[RequestOptions] = None, |
| 289 |
) -> ChangePasswordTicketResponseContent: |
| 290 |
""" |
| 291 |
Create a password change ticket for a given user. A password change ticket is a generated URL that the user can consume to start a reset password flow. |
| 292 |
|
| 293 |
Note: This endpoint does not verify the given user’s identity. If you call this endpoint within your application, you must design your application to verify the user’s identity. |
| 294 |
|
| 295 |
Parameters |
| 296 |
---------- |
| 297 |
result_url : typing.Optional[str] |
| 298 |
URL the user will be redirected to in the classic Universal Login experience once the ticket is used. Cannot be specified when using organization_id. May be specified together with client_id when the tenant has a custom password reset page enabled and a password-reset-post-challenge Action bound. |
| 299 |
|
| 300 |
user_id : typing.Optional[str] |
| 301 |
user_id of for whom the ticket should be created. |
| 302 |
|
| 303 |
client_id : typing.Optional[str] |
| 304 |
ID of the client (application). If provided for tenants using the New Universal Login experience, the email template and UI displays application details, and the user is prompted to redirect to the application's <a target='' href='https://auth0.com/docs/authenticate/login/auth0-universal-login/configure-default-login-routes#completing-the-password-reset-flow'>default login route</a> after the ticket is used. client_id is required to use the <a target='' href='https://auth0.com/docs/customize/actions/flows-and-triggers/post-change-password-flow'>Password Reset Post Challenge</a> trigger. |
| 305 |
|
| 306 |
organization_id : typing.Optional[str] |
| 307 |
(Optional) Organization ID – the ID of the Organization. If provided, organization parameters will be made available to the email template and organization branding will be applied to the prompt. In addition, the redirect link in the prompt will include organization_id and organization_name query string parameters. |
| 308 |
|
| 309 |
connection_id : typing.Optional[str] |
| 310 |
ID of the connection. If provided, allows the user to be specified using email instead of user_id. If you set this value, you must also send the email parameter. You cannot send user_id when specifying a connection_id. |
| 311 |
|
| 312 |
email : typing.Optional[str] |
| 313 |
Email address of the user for whom the tickets should be created. Requires the connection_id parameter. Cannot be specified when using user_id. |
| 314 |
|
| 315 |
ttl_sec : typing.Optional[int] |
| 316 |
Number of seconds for which the ticket is valid before expiration. If unspecified or set to 0, this value defaults to 432000 seconds (5 days). |
| 317 |
|
| 318 |
mark_email_as_verified : typing.Optional[bool] |
| 319 |
Whether to set the email_verified attribute to true (true) or whether it should not be updated (false). |
| 320 |
|
| 321 |
include_email_in_redirect : typing.Optional[bool] |
| 322 |
Whether to include the email address as part of the returnUrl in the reset_email (true), or not (false). |
| 323 |
|
| 324 |
identity : typing.Optional[ChangePasswordTicketIdentity] |
| 325 |
|
| 326 |
request_options : typing.Optional[RequestOptions] |
| 327 |
Request-specific configuration. |
| 328 |
|
| 329 |
Returns |
| 330 |
------- |
| 331 |
ChangePasswordTicketResponseContent |
| 332 |
Ticket successfully created. |
| 333 |
|
| 334 |
Examples |
| 335 |
-------- |
| 336 |
import asyncio |
| 337 |
|
| 338 |
from auth0 import AsyncAuth0 |
| 339 |
|
| 340 |
client = AsyncAuth0( |
| 341 |
token="YOUR_TOKEN", |
| 342 |
) |
| 343 |
|
| 344 |
|
| 345 |
async def main() -> None: |
| 346 |
await client.tickets.change_password() |
| 347 |
|
| 348 |
|
| 349 |
asyncio.run(main()) |
| 350 |
""" |
| 351 |
_response = await self._raw_client.change_password( |
| 352 |
result_url=result_url, |
| 353 |
user_id=user_id, |
| 354 |
client_id=client_id, |
| 355 |
organization_id=organization_id, |
| 356 |
connection_id=connection_id, |
| 357 |
email=email, |
| 358 |
ttl_sec=ttl_sec, |
| 359 |
mark_email_as_verified=mark_email_as_verified, |
| 360 |
include_email_in_redirect=include_email_in_redirect, |
| 361 |
identity=identity, |
| 362 |
request_options=request_options, |
| 363 |
) |
| 364 |
return _response.data |